Closed
Description
Related to #96429. It's a serious bug that breaks lifecycle control flow on iOS. This issue could be introduced by flutter/plugins#4140.
Steps to Reproduce
- Run the example of the
camera
plugin like the first install (uninstall first if it's installed). - Request for a camera instance.
- Exception is thrown.
======== Exception caught by widgets library =======================================================
The following assertion was thrown building CameraPreview:
A CameraController was used after being disposed.
Once you have called dispose() on a CameraController, it can no longer be used.
Details
From the screenshot, we can recognize that the initialize
method completes before permissions requests are done. This could be affected by the thread model changing of implementations on iOS.
Once the new controller has been given to the field, the lifecycle listener is triggered a bit later, which will dispose the controller in a short time, causing a race condition issue.
And after the app is resumed, the controller will initialize again.
Environment
camera: 0.9.4+6