8000 Exception when application exits on Android · Issue #578 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

Exception when application exits on Android #578

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

Open
pan1nx opened this issue Jun 3, 2021 · 1 comment
Open

Exception when application exits on Android #578

pan1nx opened this issue Jun 3, 2021 · 1 comment

Comments

@pan1nx
Copy link
Contributor
pan1nx commented Jun 3, 2021

Describe the bug

When Android application exits (user closes the application), there is an null-pointer exception thrown:

Exception 'java.lang.NullPointerException' occurred in thread 'main' at com.cloudwebrtc.webrtc.FlutterWebRTCPlugin.onDetachedFromActivity(FlutterWebRTCPlugin.java:97)

Suggestion how to fix

In FlutterWebRTCPlugin.java @ L97 (https://github.com/flutter-webrtc/flutter-webrtc/blob/master/android/src/main/java/com/cloudwebrtc/webrtc/FlutterWebRTCPlugin.java#L97) patch it like this:

         if (this.observer != null) {
             this.lifecycle.removeObserver(this.observer);
-            this.application.unregisterActivityLifecycleCallbacks(this.observer);
+            if (this.application != null) {
+                this.application.unregisterActivityLifecycleCallbacks(this.observer);
+            }
         }

To Reproduce

Create an Android application and use flutter_webrtc. When exit the application, the exception is thrown.

Expected behavior

Exit gracefully.

Platform information

  • Flutter version: Flutter (Channel beta, 2.2.0, on Linux, locale en_US.UTF-8), Flutter version 2.2.0, Framework revision b22742018b (3 weeks ago), Engine revision a9d88a4d18, Dart version 2.13.0

  • Plugin version: 0.6.4

  • OS: Android

  • OS version: Any API >= 23 showed same behavior

@dnkoulouris
Copy link

same here

cloudwebrtc pushed a commit that referenced this issue Jun 7, 2021
When application exits, it throws an exception:
Exception 'java.lang.NullPointerException' occurred in thread 'main' at com.cloudwebrtc.webrtc.FlutterWebRTCPlugin.onDetachedFromActivity(FlutterWebRTCPlugin.java:97)

See also issue #578

Signed-off-by: Peter Antoniac <pan1nx+flutterwebrtc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0