Skip to content

Camera initialization fails when re-running the app without stopping it #176451

Closed
flutter/packages
#10571

Description

@giordy16

Steps to reproduce

Run the official example. Then re-run the app without stopping it.
See #176288 (comment)

I guess has something to do with the migration from camera_android to camera_android_camerax, since with camera: 0.10.6 the problem doesn't happen.

Expected results

App shouldn't crash

Actual results

App crash

Code sample

official example

Logs

Logs
E/AndroidRuntime(11999): FATAL EXCEPTION: main
E/AndroidRuntime(11999): Process: com.lucagiordano.app.test.test_app, PID: 11999
E/AndroidRuntime(11999): java.lang.IllegalArgumentException: Unsupported value: 'io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl@dfca9e2' of type 'io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl'
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.CameraXLibraryPigeonProxyApiBaseCodec.writeValue(CameraXLibrary.g.kt:971)
E/AndroidRuntime(11999): 	at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:277)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.CameraXLibraryPigeonCodec.writeValue(CameraXLibrary.g.kt:1369)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.CameraXLibraryPigeonProxyApiBaseCodec.writeValue(CameraXLibrary.g.kt:853)
E/AndroidRuntime(11999): 	at io.flutter.plugin.common.StandardMessageCodec.encodeMessage(StandardMessageCodec.java:76)
E/AndroidRuntime(11999): 	at io.flutter.plugin.common.BasicMessageChannel.send(BasicMessageChannel.java:107)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.PigeonApiObserver.onChanged(CameraXLibrary.g.kt:1900)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl$1.run(ObserverProxyApi.java:32)
E/AndroidRuntime(11999): 	at android.app.Activity.runOnUiThread(Activity.java:7074)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.ProxyApiRegistrar.runOnMainThread(ProxyApiRegistrar.java:84)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl.onChanged(ObserverProxyApi.java:28)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
E/AndroidRuntime(11999): 	at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.redirectTo$lambda$2$lambda$0(LiveDataUtil.kt:93)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.$r8$lambda$V9EBonQFq1dAKwmRnh8LBc1iwpk(Unknown Source:0)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.redirectTo$lambda$2$lambda$1(LiveDataUtil.kt:93)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.$r8$lambda$TCWj4oM3TKXgmbBeE1jMGz0gCa4(Unknown Source:0)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData$$ExternalSyntheticLambda1.onChanged(D8$$SyntheticClass:0)
E/AndroidRuntime(11999): 	at androidx.lifecycle.MediatorLiveData$Source.onChanged(MediatorLiveData.java:171)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
E/AndroidRuntime(11999): 	at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
E/AndroidRuntime(11999): 	at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(11999): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11999): 	at android.os.Looper.loop(Looper.java:233)
E/AndroidRuntime(11999): 	at android.app.ActivityThread.main(ActivityThread.java:8068)
E/AndroidRuntime(11999): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11999): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
E/AndroidRuntime(11999): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)

Flutter Doctor output

Doctor output
lucagiordano@Lucas-MacBook-Pro test_app % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.5, on macOS 15.3.2 24D81 darwin-arm64, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.104.2)
[✓] Connected device (5 available)
    ! Error: Browsing on the local area network for Hello Bob. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.

Activity

  1. tirth-patel-nc commented on Oct 3, 2025

    @tirth-patel-nc
    Member

    Thanks for the report. Seeing the same behaviour with latest SDK versions with official example and hot-restart while using camera_android_camerax. It was reported in a comment #169506 (comment). I triaged it in my findings #169506 (comment).

    Doesn't occur with camera_android. Doesn't occur with camera 0.10.6.

    stable : 3.35.5
    master : 3.37.0-1.0.pre-395
    
  2. added
    platform-androidAndroid applications specifically
    team-androidOwned by Android platform team
    c: regressionIt was better in the past than it is now
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    toolAffects the "flutter" command-line tool. See also t: labels.
    t: hot reloadReloading code during "flutter run"
    and removed
    in triagePresently being triaged by the triage team
    on Oct 3, 2025
  3. added
    P2Important issues not at the top of the work list
    on Oct 7, 2025
  4. 1 remaining item

  5. AbhiCodebugger commented on Nov 12, 2025

    @AbhiCodebugger
  6. JuYiYang commented on Nov 22, 2025

    @JuYiYang
  7. callmephil commented on Nov 26, 2025

    @callmephil
  8. github-actions commented on Dec 24, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listd: examplesSample code and demosfound in release: 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: hot reloadReloading code during "flutter run"team-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions