Android console displays: W/art: Attempt to remove non-JNI local reference

雨燕双飞 提交于 2020-01-12 04:03:05

问题


I've just setup my first Cordova project and installed OneSignal push notifications. This is all working as I expect, however the Android Developer Tools are showing this in the console:

W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
I/art: WaitForGcToComplete blocked for 6.202ms for cause Background
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Attempt to remove non-JNI local reference, dumping thread

This message is constantly output while the app is running.

What does it mean and how can I resolve whatever issue there is?


回答1:


The entries are not related to OneSignal. From the following threads this looks to be a bug with the WebView and can happen more often on enumerators while using host GPU is off. See the below threads referring to this.

  • Android webview using GSAP: Attempt to remove non-JNI local reference, dumping thread
  • https://forum.ionicframework.com/t/ionic-app-crashing-only-on-android-emulator/33375/2



回答2:


It seems that the problem is related to this Chromium bug. Quoting the bug report:

On recent versions of ART with CheckJNI turned on, this causes a spammy warning to be printed to logcat stating "Attempt to remove non-JNI local reference, dumping thread" with a thread dump, as apparently parameters are not supposed to be deleted, only objects returned as local references from native->java JNI calls. This is not actually a problem since the runtime just does nothing in this case (other than printing the warning), but it's spammy for webview-using applications that may want to run development builds with checkjni enabled.

This is different from the host GPU emulation issue, which would crash the app instead of letting it run with spammy warnings.

I've looked quite a bit, but couldn't find a way to disable CheckJNI on ART (even though it is possible for Dalvik). My current workaround is to filter the logcat. To do this, select the text of the warning in the logcat window of Android Studio, then right click it and choose Fold lines like this.




回答3:


If you're a developer getting this message in your own app, make sure you're not accidentally deleting local references given as parameters to your JNI methods.

i.e. don't do this:

JNIEXPORT void JNICALL Java_my_app_MyClass_myMethod
    (JNIEnv* env, jobject self, jobject someParam) {
    env->DeleteLocalRef(someParam);
}


来源:https://stackoverflow.com/questions/40145667/android-console-displays-w-art-attempt-to-remove-non-jni-local-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!