Skip to content

[firebase_messaging] background messaging "Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed." #2196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hw-dwalter opened this issue Mar 18, 2020 · 2 comments
Labels
type: bug Something isn't working

Comments

@hw-dwalter
Copy link

Describe the bug
If the app is ended with the back button, background message handler is still working (as expected).
But if the app is started again and switched to background, dart message handler is not called and strange debug messages appear:

Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed.
D/FA      ( 4909): Application going to the background
W/FlutterJNI( 4909): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: plugins.flutter.io/firebase_messaging_background. Response ID: 1

Application.kt:

public class Application: FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry) {
        CustomPluginRegistrant.registerWith(registry)
    }
}

CustomPluginRegistrant.kt:

class CustomPluginRegistrant {
    companion object {
        fun registerWith(registry: PluginRegistry) {
            if (alreadyRegisteredWith(registry)) {
                return;
            }

            FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
        }

        fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
            val key = CustomPluginRegistrant::class.java.name
            if (registry.hasPlugin(key)) {
                return true
            }
            registry.registrarFor(key)
            return false
        }
    }
}

flutter doctor -v:

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Linux, locale de_DE.UTF-8) • Flutter version 1.12.13+hotfix.8 at /opt/flutter • Framework revision 0b8abb4724 (5 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /home/dwalter/Android/Sdk/
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /home/dwalter/Android/Sdk/
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.

[!] Android Studio (version 3.5)
• Android Studio at /opt/android-studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Community Edition (version 2019.3)
• IntelliJ at /opt/idea-IC-193.6494.35
• Flutter plugin version 43.0.3
• Dart plugin version 193.6494.35

[✓] Connected device (1 available)
• VOG L29 • 22X7N19329008040 • android-arm64 • Android 10 (API 29)

@hw-dwalter hw-dwalter added the type: bug Something isn't working label Mar 18, 2020
@hw-dwalter
Copy link
Author

Here is sample project https://github.com/hw-dwalter/flutter-firebase-messaging-background-example and video https://youtu.be/frhnHX8Z-UQ demonstrating the bug.

@hw-dwalter
Copy link
Author

solved by this pull request #1774

@firebase firebase locked and limited conversation to collaborators Aug 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant