Skip to content

[firebase_messaing]: android.os.MessageQueue.nativePollOnce (Native method) #12832

Description

@Cengizhanerturan

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

In-App Messaging

Which platforms are affected?

Android

Description

Hi;

When a notification is sent while the application is in the foreground, it crashes with the android.os.MessageQueue.nativePollOnce (Native method) error.
There is no issue with the first notification; it arrives promptly. However, subsequent notifications experience delays. After a while, all pending notifications arrive simultaneously, leading to a crash of the application.

Additionally, notifications are sent via "firebase-admin".

This problem has increased a lot in the last 6-7 months and continues to cause a lot of anr. I am submitting the "Logs & Breadcrumbs" and "Stack trace" information I received from Firebase Crashlytics.

Number of anr received in the last 90 days (31K);
crashlytics_anr_count

main (native):tid=1 systid=18662 
#00 pc 0x86f8c libc.so (syscall + 28)
#01 pc 0x1b07a4 libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 148)
#02 pc 0x3a544c libart.so (art::JNI<false>::CallObjectMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) + 500)
#03 pc 0x4074 libnativehelper.so (_JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, ...) + 124)
#04 pc 0xed358 libandroid_runtime.so (android::NativeDisplayEventReceiver::dispatchVsync(long, unsigned long, unsigned int) + 48)
#05 pc 0x93c28 libgui.so (android::DisplayEventDispatcher::handleEvent(int, int, void*) + 168)
#06 pc 0x1a064 libutils.so (android::Looper::pollInner(int) + 916)
#07 pc 0x19c68 libutils.so (android::Looper::pollOnce(int, int*, int*, void**) + 112)
#08 pc 0x118b3c libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int) + 44)
       at android.os.MessageQueue.nativePollOnce(Native method)
       at android.os.MessageQueue.next(MessageQueue.java:335)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:8096)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)

crashlytics_ss_1
crashlytics_ss_2
crashlytics_ss_3

[✓] Flutter (Channel stable, 3.13.5, on macOS 14.4.1 23E224 darwin-arm64, locale tr)
    • Flutter version 3.13.5 on channel stable at /Users/cengizhan/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 12fccda598 (8 ay önce), 2023-09-19 13:56:11 -0700
    • Engine revision bd986c5ed2
    • Dart version 3.1.2
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/cengizhan/Development/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/cengizhan/Development/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.76.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 125.0.6422.76

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Packages

firebase_core: ^2.21.0
firebase_messaging: ^14.7.3

Reproducing the issue

  1. Launch the application on an Android device.
  2. Send multiple push notifications to the device within a short period.
  3. Notice the delay in receiving subsequent notifications.
  4. After some time, observe all pending notifications being delivered simultaneously, leading to a crash of the application.

Firebase Core version

2.21.0

Flutter Version

3.13.5

Relevant Log Output

main (native):tid=1 systid=18662 
#00 pc 0x86f8c libc.so (syscall + 28)
#01 pc 0x1b07a4 libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 148)
#02 pc 0x3a544c libart.so (art::JNI<false>::CallObjectMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) + 500)
#03 pc 0x4074 libnativehelper.so (_JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, ...) + 124)
#04 pc 0xed358 libandroid_runtime.so (android::NativeDisplayEventReceiver::dispatchVsync(long, unsigned long, unsigned int) + 48)
#05 pc 0x93c28 libgui.so (android::DisplayEventDispatcher::handleEvent(int, int, void*) + 168)
#06 pc 0x1a064 libutils.so (android::Looper::pollInner(int) + 916)
#07 pc 0x19c68 libutils.so (android::Looper::pollOnce(int, int*, int*, void**) + 112)
#08 pc 0x118b3c libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int) + 44)
       at android.os.MessageQueue.nativePollOnce(Native method)
       at android.os.MessageQueue.next(MessageQueue.java:335)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:8096)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)

Flutter dependencies

Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions