Skip to content

[firebase_messaging] Crash when set onBackgroundMessage #125

@festelo

Description

@festelo

The following code causes immediate crash after app launching:

// Top Level. I also tried code from readme, no success.
Future<dynamic> myBackgroundMessageHandler(dynamic message) {
  return Future.value(0);
}

_firebaseMessaging.configure(
      onMessage: (d) async { print('on message'); handleMessage(d); },
      onBackgroundMessage: myBackgroundMessageHandler,
      onLaunch: (d) async { print('on launch'); handleMessage(d); },
      onResume: (d) async { print('on resume'); handleMessage(d); },
    );

If myBackgroundMessageHandler method isn't on top level, then it's not crashing, but throws null exception ("'toRawHandle' was called on null")

Without onBackgroundMessage: myBackgroundMessageHandler, all works fine.

Application.java class:

package com.protreal;

import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

public class Application extends FlutterApplication implements PluginRegistrantCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        GeneratedPluginRegistrant.registerWith(registry);
    }
}

compileSdkVersion - 28
google-services version - 4.3.0

Crash log:

V/FA      (24891): Inactivity, disconnecting from the service
F/libc    (24891): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1 in tid 24938 (Thread-3), pid 24891 (com.protreal)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Xiaomi/cepheus/cepheus:9/PKQ1.181121.001/V10.2.3.0.PFAMIXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 24891, tid: 24938, name: Thread-3  >>> com.protreal <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1
Cause: null pointer dereference
    x0  0000000000000001  x1  0000007e86488660  x2  0000007e86400000  x3  0000000000000002
    x4  0000000000000088  x5  0000000000000000  x6  0000007e723beef0  x7  00000000000038c7
    x8  0000007e6abb7b60  x9  0000007e6abb7b60  x10 00000000000000e3  x11 0000000000000000
    x12 0000000000000003  x13 0000000000000010  x14 0020e0a7d87b2613  x15 0000007e723beef0
    x16 0000007f11519bd0  x17 0000007f1149ac28  x18 0000000000000010  x19 0000007e68c3b6e0
    x20 0000007e88844d40  x21 0000007e68227e60  x22 0000007e68227e90  x23 0000007e81778b98
    x24 000000000000003b  x25 0000007e723bf260  x26 0000007e723bf588  x27 000000000000003b
    x28 0000000000000001  x29 0000007e723bf3a0
    sp  0000007e723bf0f0  lr  0000007e73128078  pc  0000007e73124350
backtrace:
    #00 pc 0000000000d64350  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #01 pc 0000000000d68074  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #02 pc 0000000000d5fc0c  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #03 pc 0000000000d65f88  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #04 pc 0000000000d66664  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #05 pc 0000000000d65a88  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #06 pc 0000000000d6ac00  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #07 pc 0000000000014ff8  /system/lib64/libutils.so (android::Looper::pollInner(int)+836)
    #08 pc 0000000000014c18  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+60)
    #09 pc 00000000000122a4  /system/lib64/libandroid.so (ALooper_pollOnce+96)
    #10 pc 0000000000d6ab84  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #11 pc 0000000000d659d4  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #12 pc 0000000000d68ad8  /data/app/com.protreal-Sp4ZeyXWIfVaHXpYDtdueg==/lib/arm64/libflutter.so (offset 0xd50000)
    #13 pc 000000000009043c  /system/lib64/libc.so (__pthread_start(void*)+36)
    #14 pc 0000000000023c38  /system/lib64/libc.so (__start_thread+68)
Lost connection to device.

On Xiaomi Mi 9 (9.0.0) & Genymotion virtual device (7.1.0) (gservices installed)

Metadata

Metadata

Assignees

Labels

impact: criticalUsually a production crash with high user impact. (P1)impact: crowdAffects many people, though not necessarily a specific customer with an assigned label. (P2)plugin: messagingtype: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions