flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.18k stars 26.65k forks source link

[camera] IllegalStateException io.flutter.embedding.engine.dart.DartMessenger$Reply in reply #147416

Closed melWiss closed 1 week ago

melWiss commented 2 weeks ago

Steps to reproduce

Steps to reproduce isn't so clear, this exception is reported using Sentry and judging from the exception stack, it's coming from camera plugin and it's only happening on Samsung devices. It probably happens after using the camera.

io.flutter.embedding.engine.dart.DartMessenger$Reply in reply at line 435
io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1 in error at line 268
io.flutter.plugins.camera.DartMessenger in lambda$error$2 at line 198
io.flutter.plugins.camera.DartMessenger$$ExternalSyntheticLambda2 in run at line 8
android.os.Handler in handleCallback at line 958
android.os.Handler in dispatchMessage at line 99
android.os.Looper in loopOnce at line 230
android.os.Looper in loop at line 319
android.app.ActivityThread in main at line 8893
java.lang.reflect.Method in invoke
com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 608
com.android.internal.os.ZygoteInit in main at line 1103

It'll be nice if there's a way to catch native exception that is coming from plugins

Expected results

the exception should not happen and if it does there should be at least a way to catch native exceptions. or we can have this following suggestion

MethodChannel(flutterEngine.dartExecutor.binaryMessenger, METHOD_CHANNEL).setExceptionHandler(

Actual results

the exception happens and it's crashing the app with no way to reproduce it

Code sample

Code sample ```dart [Paste your code here] ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console java.lang.IllegalStateException: Reply already submitted at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:435) at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:268) at io.flutter.plugins.camera.DartMessenger.lambda$error$2(DartMessenger.java:198) at io.flutter.plugins.camera.DartMessenger$$ExternalSyntheticLambda2.run at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8893) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) ```

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [!] Flutter (Channel [user-branch], 3.13.8, on Microsoft Windows [Version 10.0.22631.3374], locale fr-FR) ! Flutter version 3.13.8 on channel [user-branch] at C:\Users\oussa\flutter Currently on an unknown channel. Run `flutter channel` to switch to an official channel. If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. ! Upstream repository unknown source is not a standard remote. Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error. [✓] Windows Version (Installed version of Windows is version 10 or higher) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [✓] Chrome - develop for the web [✓] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.5.1) [✓] Android Studio (version 2022.1) [✓] VS Code (version 1.88.1) [✓] Connected device (3 available) [✓] Network resources ! Doctor found issues in 1 category. ```
khalilyamoun commented 2 weeks ago

We are encountering the same exception in one of our applications.

huycozy commented 2 weeks ago

Hi @melWiss, @khalilyamoun Which camera_android plugin version are you using? (Please find it in pubspec.lock file).

Could you also share the entire crash stack trace if any? (to see if this is similar to a case at https://github.com/flutter/flutter/issues/88598)

melWiss commented 2 weeks ago

for the camera plugin, it's camera_android: 0.10.8+16

for the stack trace, this is all what we have:

java.lang.IllegalStateException: Reply already submitted
    at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:435)
    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:268)
    at io.flutter.plugins.camera.DartMessenger.lambda$error$2(DartMessenger.java:198)
    at io.flutter.plugins.camera.DartMessenger$$ExternalSyntheticLambda2.run
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:230)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8893)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
huycozy commented 2 weeks ago

Thanks for the update. Does this occur if you run your project in release mode? If it does, please share the entire crash stack trace that may help us investigate this further.

melWiss commented 2 weeks ago

the problem is it didn't occur on our end, our users faced the exception and it was reported by sentry, what we can say is that after taking the picture the exception happens and i tried the fix mentioned here https://github.com/flutter/flutter/issues/88598 but with no luck

huycozy commented 1 week ago

https://github.com/flutter/flutter/issues/88598 is still open and needs to investigate further. I would suggest you follow up on that issue. It would be helpful if you can find a pattern to reproduce it. Closing this in favor of https://github.com/flutter/flutter/issues/88598.