Firebase crashlytics recently started logging one ANR related to FragmentManager.
Below is the concise Stacktrace ->
main (runnable): tid=1 systid=14811
#00 pc 0x483028 libart.so
#01 pc 0x588888 libart.so
#02 pc 0x5a56d4 libart.so
#03 pc 0x589564 libart.so
#04 pc 0x6286ec libart.so
at java.lang.Throwable.nativeFillInStackTrace(Throwable.java)
at java.lang.Throwable.fillInStackTrace(Throwable.java:799)
at java.lang.Throwable.(Throwable.java:277)
at java.lang.Exception.(Exception.java:66)
at java.lang.RuntimeException.(RuntimeException.java:62)
at androidx.fragment.app.strictmode.Violation.(Violation.kt:28)
at androidx.fragment.app.strictmode.SetUserVisibleHintViolation.(SetUserVisibleHintViolation.kt:30)
at androidx.fragment.app.strictmode.FragmentStrictMode.onSetUserVisibleHint(FragmentStrictMode.java:131)
at androidx.fragment.app.Fragment.setUserVisibleHint(Fragment.java:1335)
at androidx.fragment.app.FragmentStatePagerAdapter.instantiateItem(FragmentStatePagerAdapter.java:196)
at com.frran.ui.adapter.HomeMenuPagerAdapter.instantiateItem(HomeMenuPagerAdapter.java:106)
at com.frran.ui.custom.viewpager.PagerAdapterWrapper.instantiateItem(PagerAdapterWrapper.java:56)
at com.frran.ui.custom.viewpager.RtlViewPager$ReverseAdapter.instantiateItem(RtlViewPager.java:192)
at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1224)
at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:669)
at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:631)
at androidx.viewpager.widget.ViewPager.setCurrentItem(ViewPager.java:623)
at com.frran.ui.custom.viewpager.RtlViewPager.setCurrentItem(RtlViewPager.java:74)
Dependencies i am using ->
def fragment_version = "1.4.1"
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "androidx.appcompat:appcompat:1.3.1"
I am using FragmentStatePagerAdapter with default behavior BEHAVIOR_SET_USER_VISIBLE_HINT i think it has something to do with it but i can not find anything to back this up.
Looking at the fragment version 1.4.0 release notes i found FragmentStrictMode is available to debug the fragment . but it clearly says with the default policy it will not anything if disabled and i did not enabled it manually.
Can i get some help on this Since its a Violation logged by FragmentStrictMode do i have to worry about this ? if not how come crashlytics is logging it even if its disabled in release build.
Related
I am getting a lot of ANR's in ContentResolver in Firebase Crashlytics since updating all external google libraries and targetSDKVersion 32.
Are there any changes for ContentResolver I have missed in newer libraries/Android version?
For example, I get an ANR if I call my ContentResolver to get only a count:
at com.xxxx.xxx.db.xxxDatabase.getxxxsCount(xxxDatabase.java:1470)
main (native): tid=1 systid=14120
#00 pc 0x4f55c libc.so (syscall + 28)
#01 pc 0x47cc80 libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 140)
#02 pc 0x75b88c libart.so (artJniMethodEnd + 204)
#03 pc 0x20facc libart.so (art_jni_method_end + 12)
at android.os.BinderProxy.transactNative(BinderProxy.java)
at android.os.BinderProxy.transact(BinderProxy.java:584)
at android.content.IContentService$Stub$Proxy.unregisterContentObserver(IContentService.java:1005)
at android.content.ContentResolver.unregisterContentObserver(ContentResolver.java:2730)
at android.database.AbstractCursor.onDeactivateOrClose(AbstractCursor.java:157)
at android.database.AbstractWindowedCursor.onDeactivateOrClose(AbstractWindowedCursor.java:213)
at android.database.AbstractCursor.close(AbstractCursor.java:186)
at android.database.sqlite.SQLiteCursor.close(SQLiteCursor.java:207)
at android.database.CursorWrapper.close(CursorWrapper.java:54)
at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:3870)
at com.xxxx.xxx.db.xxxDatabase.getxxxsCount(xxxDatabase.java:1470)
at com.xxxx.xxx.db.xxxDatabase.getFiredOffxxxsCount(xxxDatabase.java:1361)
at com.xxxx.xxx.utilities.xxxNotification.shouldGroup(xxxNotification.java:999)
at com.xxxx.xxx.utilities.xxxNotification.getNotification(xxxNotification.java:720)
at com.xxxx.xxx.utilities.xxxNotification.buildNotification(xxxNotification.java:522)
at com.xxxx.xxx.utilities.xxxNotification.buildNotification(xxxNotification.java:451)
at com.xxxx.xxx.utilities.xxxNotification.updateNotificationGroup(xxxNotification.java:1318)
at com.xxxx.xxx.utilities.xxxNotification.cancelNotification(xxxNotification.java:335)
at com.xxxx.xxx.utilities.xxxNotification.snooze(xxxNotification.java:1915)
at com.xxxx.xxx.AlarmList.snoozeAllNewAlarmTime(AlarmList.java:80)
at com.xxxx.xxx.AlarmList.onFinishSnoozeDialog(AlarmList.java:117)
at com.xxxx.xxx.dialogs.SnoozeDialog.onClick(SnoozeDialog.java:279)
at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I have not changed any code, so I am wondering why this is now happening after upgrading. I think I have missed any background changes in AndroidX or Android SDK 32 version for ContentResolver or queries.
I know this is very generic, but currently I don't know where to check for the problem.
I would be grateful for any help or hint.
Update 28.09.2022:
I get also sometimes ANR's where no class is involved of my app.
main (native): tid=1 systid=9452
#00 pc 0xd6a94 libc.so (__ioctl + 4)
#01 pc 0x935c4 libc.so (ioctl + 156)
#02 pc 0x51a7c libbinder.so (android::IPCThreadState::talkWithDriver(bool) + 296)
#03 pc 0x52a68 libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*) + 60)
#04 pc 0x527d8 libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int) + 184)
#05 pc 0x4b01c libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int) + 188)
#06 pc 0x12b3e8 libandroid_runtime.so (android_os_BinderProxy_transact(_JNIEnv*, _jobject*, int, _jobject*, _jobject*, int) + 152)
at android.os.BinderProxy.transactNative(BinderProxy.java)
at android.os.BinderProxy.transact(BinderProxy.java:540)
at bn.h(bn.java:11)
at bk.a(bk.java:3)
at bm.c(bm.java)
at be.d(be.java:2)
at bh.handleMessage(bh.java:28)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8056)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Seems the problems were about the upgrade from the Billing Library 3.x to 5.x!
After reverting to 3.x the ANR's are gone.
Now I have readded the Billing Library from scratch with version 5.x!
No more ANR's or strange behaviors anymore.
Strange, but I think there was a mistake on upgrading to 5.x and this caused some leaks.
I have a native Android, SDK style library which depends on OpenCV.
In order to avoid conflict when a user uses the library and their own usage with OpenCV, I want to compile OpenCV statically into my library and hide its symbols.
I compiled OpenCV (3.4.13 world module) statically and used it, along with its 3rd party libraries in my library.
When I try and use my library, and it throws an exception, even if the exception is caught by the user, a SIGABRT is causing the app to terminate.
This is the stack trace from the logcat
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24115 (.test), pid 24115 (.test)
...
A/DEBUG: backtrace:
A/DEBUG: #00 pc 0000000000051948 /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: 931371c1098ffd5adc489b9ff4da8e82)
A/DEBUG: #01 pc 00000000000b2ba0 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libc++_shared.so (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
A/DEBUG: #02 pc 00000000000aec8c /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libc++_shared.so (__gxx_personality_v0+348) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
A/DEBUG: #03 pc 00000000004dd2dc /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #04 pc 00000000004dd7e4 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #05 pc 0000000000170600 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (mylib::TestClass::TestClass(char const*, char const*)+908) (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #06 pc 000000000000c5d0 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #07 pc 000000000000c3b8 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #08 pc 000000000000c308 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (Java_com_example_lib_Engine_cxxInit+56) (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #09 pc 00000000002d7644 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 2b417e2566f5eb686666666b6ee952ea)
(It also happens if the JNI library uses c++_static, but in that case the __gxx_personality_v0 and 1 above it come from the libJnilibrary.so)
If I compile OpenCV as a shared library and link my library against it, then everything works fine.
I've had issues with exceptions in my library before, see this question I asked. I solved it by compiling everything using c++_static STL. The problem looks similar to this, and indeed I was missing the key function, but even after adding it, the problem keeps happening.
I looked at the symbols using llvm-readelf -CWs and noticed that when OpenCV is linked dynamically, in addition to OpenCV symbols, the output contains some ndk and cxxabi symbols which doesn't exist when OpenCV is used statically. I don't know if it's related at all but for example
110: 0000000000000000 0 FUNC GLOBAL DEFAULT UND std::uncaught_exception()
...
201: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND vtable for __cxxabiv1::__vmi_class_type_info
...
231: 0000000000000000 0 FUNC GLOBAL DEFAULT UND std::__ndk1::to_string(unsigned int)
(All of these are missing when using statically built OpenCV)
I'm using ndk version 21e (I can't use higher version at the moment because another library uses Bazel and it only supports up to 21 at the moment)
OpenCV is built with the following flags
cmake -DCMAKE_BUILD_TYPE=Release -DINSTALL_ANDROID_EXAMPLES=OFF -DANDROID_EXAMPLES_WITH_LIBS=OFF -DANDROID_ABI="arm64-v8a"
-DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DWITH_OPENCL=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DANDROID_ARM_NEON=1
-DANDROID_STL=c++_static -DANDROID_PLATFORM=android-21 -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake"
-DBUILD_SHARED_LIBS=OFF -DBUILD_FAT_JAVA_LIB=OFF -DBUILD_JAVA=OFF -DINSTALL_CREATE_DISTRIB=ON -DINSTALL_ANDROID_EXAMPLES=OFF -DBUILD_opencv_objdetect=OFF
-DBUILD_opencv_video=ON -DBUILD_opencv_videoio=ON -DBUILD_opencv_features2d=ON -DBUILD_opencv_flann=OFF -DBUILD_opencv_highgui=ON -DBUILD_opencv_ml=OFF
-DBUILD_opencv_photo=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_shape=OFF -DBUILD_opencv_stitching=OFF -DBUILD_opencv_superres=OFF -DBUILD_opencv_ts=OFF
-DBUILD_opencv_videostab=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_opencv_world=ON -DBUILD_opencv_dnn=OFF -DBUILD_opencv_core=ON -DBUILD_opencv_imgcodecs=ON
-DBUILD_opencv_imgproc=ON -DBUILD_opencv_calib3d=ON -GNinja -DCMAKE_INSTALL_PREFIX=../install -DBUILD_ZLIB=1 -DWITH_PROTOBUF=OFF -DWITH_QUIRC=OFF ..
My libray is compiled using Gradle and Android Studio with these CMake flags
externalNativeBuild {
cmake {
cppFlags "-std=c++17 -static-openmp -fopenmp -fexceptions -frtti -Wno-unused-command-line-argument -Wl,-s"
cppFlags "-Wl,--exclude-libs,libc++_static.a -Wl,--exclude-libs,libc++abi.a"
arguments "-DANDROID_STL=c++_static", "-DANDROID_ARM_NEON=TRUE"
}
}
The issue wasn't related to the 3rd party or anything like this at all eventually.
I was using NDK version r21e. Upgrading the NDK to r24 fixed the issue.
It seems that when linking OpenCV as a shared object, it masked the actual NDK bug by importing or including some of the missing/problematic symbols and when we stopped using it, the error appeared.
When I use react-native-webrtc library in expo eject to expokit project, the android app release crash, Instead, using react-native-webrtc library in regular react-native project(not expo) is fine.
I got this error by adb logcat
06-21 10:42:44.188 24576 24576 F DEBUG : #04 pc 00000000001e79e8 /data/app/com.tsao-1/lib/arm64/libjingle_peerconnection_so.so (offset 0x1e1000)
06-21 10:42:44.189 24576 24576 F DEBUG : #05 pc 0000000000258dac /data/app/com.tsao-1/lib/arm64/libjingle_peerconnection_so.so (offset 0x1e1000)
06-21 10:42:44.189 24576 24576 F DEBUG : #06 pc 00000000002566e4 /data/app/com.tsao-1/lib/arm64/libjingle_peerconnection_so.so (offset 0x1e1000)
06-21 10:42:44.189 24576 24576 F DEBUG : #07 pc 00000000001e1020 /data/app/com.tsao-1/lib/arm64/libjingle_peerconnection_so.so (offset 0x1e1000) (JNI_OnLoad+32)
This is library link
https://github.com/react-native-webrtc/react-native-webrtc#creator
I know it is less information, but I really have no idea about what is happening, anyone have some experience in this library or any idea?
I find regular react-native project setting minifyEnabled = false, but expo setting true, finally I also changed minifyEnabled setting to false in expo project, then it work.
release {
minifyEnabled false // setting true will crash
}
https://github.com/react-native-webrtc/react-native-webrtc/issues/646
It seems this error is caused by bugs in native code, and that this is due to the Realm library -- based on seeing the phrase librealm-jni.so in the "Build Fingerprint" beneath the error. I have the latest version of Realm installed -- 1.2.0.
Here's the error code:
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x14c in tid 7837 (ator.app)
Here's the "Build Fingerprint:"
Build fingerprint: 'generic/vbox86p/vbox86p:5.0/LRX21M/buildbot11172321:userdebug/test-keys'
26643-26643/? I/DEBUG: Revision: '0'
26643-26643/? I/DEBUG: ABI: 'x86'
26643-26643/? I/DEBUG: pid: 7837, tid: 7837, name: ator.app >>> com.lockedout.app <<<
26643-26643/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x14c
26643-26643/? I/DEBUG: eax 00000148 ebx ffffffff ecx 7470d340 edx 00000002
26643-26643/? I/DEBUG: esi 00000000 edi 00000002
26643-26643/? I/DEBUG: xcs 00000023 xds 0000002b xes 0000002b xfs 00000007 xss 0000002b
26643-26643/? I/DEBUG: eip e2f6d025 ebp ffd3cd58 esp ffd3cd50 flags 00210246
26643-26643/? I/DEBUG: backtrace:
26643-26643/? I/DEBUG: #00 pc 0002a025 /data/app/com.lockedout.app-1/lib/x86/librealm-jni.so
26643-26643/? I/DEBUG: #01 pc 0009c141 /data/app/com.lockedout.app-1/lib/x86/librealm-jni.so
26643-26643/? I/DEBUG: #02 pc 0009c299 /data/app/com.lockedout.app-1/lib/x86/librealm-jni.so
26643-26643/? I/DEBUG: #03 pc 004002d3 /data/dalvik-cache/x86/data#app#com.lockedout.app-1#base.apk#classes.dex
26643-26643/? I/DEBUG: #04 pc 00000002 <unknown>
26643-26643/? I/DEBUG: Tombstone written to: /data/tombstones/tombstone_06
Update:
I narrowed down the problem to happening after I call notifyDataSetChanged on my RecyclerView.Adapter, but my code doesn't do anything else after that executes. So I narrowed down the problem area even further to line 135 in android's Looper class:
Message msg = queue.next(); // might block
I'm not sure what this means, but I imagine someone who knows the internals of Realm may be able to shed some insight on why the error is being caused in Looper.
Some more information about the changes that occured in Realm before the error:
notifyDataSetChanged is triggered inside of a RealmChangeListener set on a RealmObject aka "User". The transaction that caused the change deleted a custom RealmObject aka "Item" from User's RealmList<Item>. I know for a fact that that is the only transaction and operation that occurs because of my code. Here is the code that deletes the Item:
RealmSingleton.getUserInstance().executeTransaction(new Realm.Transaction() {
#Override
public void execute(Realm realm) {
UserSingleton.getUser().deleteItem(mItem.getClassId());
}
});
Update:
The exact line of Realm code that causes the error is line 149 in SharedGroup:
148 void commitAndContinueAsRead() {
149 nativeCommitAndContinueAsRead(nativePtr);
150 }
(I am still not an official Realm person)
Note: In order to actually answer this question, I'd have to see the full code. After all, Realm handles most possible crashes on the native side and throw it as an exception to Java, so you're probably doing something very wrong. :P
Guesses:
1.) you're using asynchronous queries combined with synchronous write on the UI thread, thus creating detached row accessors that you then try to delete based on ID despite it not being its latest version.
(Asynchronous queries aren't immediately executed, you need to listen to its completion using RealmChangeListener, but if you mix them with synchronous writes on the UI thread, you force the query to become synchronous.)
2.) You modified something on a background thread which has not yet updated the RealmResults on the UI thread (running the event handling with the looper), and the element you're trying to use in the transaction is not up to date, so its deletion crashes.
Possible solutions:
a.) Use executeTransactionAsync() instead of executeTransaction() when you're on the UI thread.
b.) In your method
UserSingleton.getUser().deleteItem(mItem.getClassId());
Not sure what UserSingleton is, but before you delete an element, you should consider requerying it based on ID inside the transaction to obtain the latest version of the element (which is potentially not updated yet in this particular case, synchronous transaction on the UI thread, after all)
Possible course of action:
If you want to help out Realm, if this crash is reproducible, consider sending the project over to help[at]realm.io so that they can look at it and fix it up. After all, you should get Java exceptions, not native crashes.
I am using cocos2dx v3.9 with ndk 10e with android 4.4.2 .I have created a layer and on that button is present . When button is pressed layer is removed from parent and clean up is performed and other task is performed. Crash is coming when button is pressed, mostly when tapped as soon as button appears.
code on button click is:-
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("tap.wav");
unschedule(schedule_selector(InstructionLayer::callNextButtonMethod));
if (this->delegate != NULL) {
delegate->clickNextButton();
} else {
CCLOG("Delegate null");
}
this->removeFromParentAndCleanup(true);
}
and my ndk crash dump is :-
********** Crash dump: **********
Build fingerprint: 'iNet/astar_ibt_8723bs/astar-ibt-8723bs:4.4.2/KVT49L/20140925:eng/test-keys'
pid: 14096, tid: 14115, name: Thread-1145 >>> com.Sample.Test <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 6d12a000
Stack frame #00 pc 00022090 /system/lib/libc.so (__memcpy_base+176)
Stack frame #01 pc 00a57f29 /data/app-lib/com.Sample.Test-2/libcocos2dcpp.so: Routine unaligned_load at /s/ndk-toolchain/src/gcc/gcc-4.9/libstdc++-v3/libsupc++/hash_bytes.cc:43
Stack frame #02 pc 00424da8 /data/app-lib/com.Sample.Test-2/libcocos2dcpp.so (std::_Hash_impl::hash(void const*, unsigned int, unsigned int)+36): Routine std::_Hash_impl::hash(void const*, unsigned int, unsigned int) at /ShobhitPC/ndk/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/functional_hash.h:131
Stack frame #03 pc 00424df8 /data/app-lib/com.Sample.Test-2/libcocos2dcpp.so (std::hash<std::string>::operator()(std::string const&) const+56): Routine std::hash<std::string>::operator()(std::string const&) const at /ShobhitPC/ndk/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:3084 (discriminator 2)