flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_messaging] Crash when set onBackgroundMessage

Open festelo opened this issue 7 years ago • 54 comments

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)

festelo avatar Sep 10 '19 15:09 festelo

I'm having the same issue.

oliwave avatar Sep 14 '19 17:09 oliwave

Any updates on this issue?

broberts-nybble avatar Sep 22 '19 08:09 broberts-nybble

I'm having the same issue

chrisurf avatar Sep 26 '19 04:09 chrisurf

I'm having a related issue here: https://github.com/FirebaseExtended/flutterfire/issues/144

ChrisOwen101 avatar Sep 26 '19 11:09 ChrisOwen101

Yup its definitely crashing

droidluv avatar Oct 04 '19 10:10 droidluv

+1, crashing for me as well

divan avatar Oct 04 '19 20:10 divan

+1 For me as well

AymanMubark avatar Oct 11 '19 11:10 AymanMubark

Same issue

[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.15 19A583, locale en-GB)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.0) [✓] Android Studio (version 3.5) [✓] VS Code (version 1.38.1) [✓] Connected device (2 available)

• No issues found!

billymahmood avatar Oct 11 '19 13:10 billymahmood

is this ever going to get fixed?

broberts-nybble avatar Oct 11 '19 13:10 broberts-nybble

+1, Same issue

weizhongshen avatar Oct 14 '19 11:10 weizhongshen

I have the same issue, but when i switch flutter channel to beta ( according to this: https://github.com/FirebaseExtended/flutterfire/issues/144) then there's no crash anymore

bthuan avatar Oct 17 '19 00:10 bthuan

Same issue here

masinamichele avatar Oct 18 '19 07:10 masinamichele

same

febg11 avatar Oct 20 '19 10:10 febg11

same

kleinpetr avatar Oct 22 '19 20:10 kleinpetr

got same issue.. any update for fix this issue...?

digarahayu avatar Oct 23 '19 03:10 digarahayu

https://github.com/mwaylabs/flutter-apns/issues/4 https://github.com/FirebaseExtended/flutterfire/issues/840

iapicca avatar Oct 23 '19 11:10 iapicca

same problem here

rlsutton1 avatar Oct 29 '19 04:10 rlsutton1

same problem. It's critical bug.

BansookNam avatar Oct 31 '19 07:10 BansookNam

same problem here, when app starts it crushes. there is no error or something in debug to know what is wrong. waiting for solution.

iampopal avatar Nov 11 '19 15:11 iampopal

same problem here

garmashev avatar Nov 13 '19 08:11 garmashev