Skip to content

[camera] Permissions request are not well-awaiting on iOS #97199

Closed
@AlexV525

Description

@AlexV525

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

  1. Run the example of the camera plugin like the first install (uninstall first if it's installed).
  2. Request for a camera instance.
  3. 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.
image

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.

image

And after the app is resumed, the controller will initialize again.

image

Environment

camera: 0.9.4+6

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: regressionIt was better in the past than it is nowhas 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