Skip to content

[camera] [crash] Methods marked with @UiThread must be executed on the main thread #72340

@xhu-ww

Description

@xhu-ww

Problem

Camera ^0.5.8+17 crashes during frequent creation and destruction on Android

java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: pool-13-thread-1

Steps to Reproduce

  1. Use BottomNavigationBar or PopupMenu to switch pages
  2. switch between the camera page and other pages multiple times
  3. crash

Crash Logs

E/AndroidRuntime(24815): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: pool-13-thread-1
E/AndroidRuntime(24815): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:992)
E/AndroidRuntime(24815): 	at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:736)
E/AndroidRuntime(24815): 	at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:72)
E/AndroidRuntime(24815): 	at io.flutter.embedding.engine.dart.DartExecutor$DefaultBinaryMessenger.send(DartExecutor.java:363)
E/AndroidRuntime(24815): 	at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:168)
E/AndroidRuntime(24815): 	at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler$EventSinkImplementation.success(EventChannel.java:221)
E/AndroidRuntime(24815): 	at io.flutter.plugins.camera.DartMessenger.send(DartMessenger.java:49)
E/AndroidRuntime(24815): 	at io.flutter.plugins.camera.Camera$4.onConfigured(Camera.java:323)
E/AndroidRuntime(24815): 	at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigured$0$CallbackProxies$SessionStateCallbackProxy(CallbackProxies.java:53)
E/AndroidRuntime(24815): 	at android.hardware.camera2.impl.-$$Lambda$CallbackProxies$SessionStateCallbackProxy$soW0qC12Osypoky6AfL3P2-TeDw.run(Unknown Source:4)
E/AndroidRuntime(24815): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(24815): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(24815): 	at java.lang.Thread.run(Thread.java:929)

Flutter Doctor

wen:flutter_necsports wangwen$ flutter doctor -v
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.14.6 18G87 darwin-x64, locale zh-Hans-CN)
    • Flutter version 1.22.5 at /Library/flutter
    • Framework revision 7891006299 (5 days ago), 2020-12-10 11:54:40 -0800
    • Engine revision ae90085a84
    • Dart version 2.10.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/wangwen/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • ANDROID_HOME = /Users/wangwen/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.0, Build version 11A420a
    • CocoaPods version 1.8.0

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ 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_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2020.2.4)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin installed
    • Dart plugin version 202.8070

[!] VS Code (version 1.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • ELE AL00 (mobile) • 8KE0219323016342 • android-arm64 • Android 10 (API 29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: fatal crashCrashes that terminate the processfound in release: 1.25Found to occur in 1.25has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions