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

35,611

Solution 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.

Solution 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.

Solution 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);
}
Share:
35,611
user1532669
Author by

user1532669

Updated on July 26, 2022

Comments

  • user1532669
    user1532669 almost 2 years

    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?