Android 控制台显示:W/art:尝试删除非 JNI 本地引用
Android console displays: W/art: Attempt to remove non-JNI local reference
我刚刚设置了我的第一个 Cordova 项目并安装了 OneSignal 推送通知。这一切都如我所料,但是 Android 开发人员工具在控制台中显示了这一点:
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
当应用处于 运行 时,此消息不断输出。
这是什么意思,我该如何解决任何问题?
条目与 OneSignal
无关。从以下线程来看,这似乎是 WebView
的错误,并且在使用 host GPU
时可能更常发生在枚举器上 off。请参阅以下与此相关的主题。
- 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
看来问题与this Chromium bug有关。引用错误报告:
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.
这与主机 GPU 模拟问题不同,主机 GPU 模拟问题会使应用程序崩溃,而不是让它 运行 带有垃圾邮件警告。
我看了很多,但找不到在 ART 上禁用 CheckJNI 的方法(即使 Dalvik 可以)。我目前的解决方法是过滤 logcat。为此,select Android Studio 的 logcat window 中的警告文本,然后右键单击它并选择 Fold lines like this
。
如果您是一名开发人员,在您自己的应用程序中收到此消息,请确保您没有意外删除作为参数提供给您的 JNI 方法的本地引用。
即不要这样做:
JNIEXPORT void JNICALL Java_my_app_MyClass_myMethod
(JNIEnv* env, jobject self, jobject someParam) {
env->DeleteLocalRef(someParam);
}
就我而言,这是因为我的 WebView (animation: donut-spin 1.2s linear infinite;
) 中有一个 CSS 动画导致出现此错误消息。
我尝试了 https://issuetracker.google.com/issues/37065041#comment10 中描述的方法,但它没有用......所以我只是评论我的 CSS 动画,而 运行 在模拟器中。
我刚刚设置了我的第一个 Cordova 项目并安装了 OneSignal 推送通知。这一切都如我所料,但是 Android 开发人员工具在控制台中显示了这一点:
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
当应用处于 运行 时,此消息不断输出。
这是什么意思,我该如何解决任何问题?
条目与 OneSignal
无关。从以下线程来看,这似乎是 WebView
的错误,并且在使用 host GPU
时可能更常发生在枚举器上 off。请参阅以下与此相关的主题。
- 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
看来问题与this Chromium bug有关。引用错误报告:
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.
这与主机 GPU 模拟问题不同,主机 GPU 模拟问题会使应用程序崩溃,而不是让它 运行 带有垃圾邮件警告。
我看了很多,但找不到在 ART 上禁用 CheckJNI 的方法(即使 Dalvik 可以)。我目前的解决方法是过滤 logcat。为此,select Android Studio 的 logcat window 中的警告文本,然后右键单击它并选择 Fold lines like this
。
如果您是一名开发人员,在您自己的应用程序中收到此消息,请确保您没有意外删除作为参数提供给您的 JNI 方法的本地引用。
即不要这样做:
JNIEXPORT void JNICALL Java_my_app_MyClass_myMethod
(JNIEnv* env, jobject self, jobject someParam) {
env->DeleteLocalRef(someParam);
}
就我而言,这是因为我的 WebView (animation: donut-spin 1.2s linear infinite;
) 中有一个 CSS 动画导致出现此错误消息。
我尝试了 https://issuetracker.google.com/issues/37065041#comment10 中描述的方法,但它没有用......所以我只是评论我的 CSS 动画,而 运行 在模拟器中。