Skip to content

[camera][add2app] FlutterEngine with camera is not destroyed #102966

@werainkhatri

Description

@werainkhatri

Steps to Reproduce

  1. Get the multiple_flutters sample.
  2. Add camera and video_player to pubspec, copy the camera example code to a separate file in lib (camera.dart) and runApp this widget in main function (shown in below details) function.
  3. Open the multiple_flutters_ios app in XCode and run the app.
  4. In-App: Click Next (opens camera example)
  5. In XCode: Click on "Debug Memory Graph" (small graph-like icon with 3 nodes at the bottom bar). In the "Show the Debug navigator" section on the left, search for FlutterEngine. Notice there is one FlutterEngine in memory (figure 1).
  6. In XCode: Click on the "Continue program execution" button (play button on the bottom bar)
  7. In-App: press Back
  8. repeat step 5, Notice that the same FlutterEngine is still active.
  9. Repeat steps 4-9, it'll add a FlutterEngine each time.
main
import 'package:camera/camera.dart'; // +
import 'package:multiple_flutters_module/camera.dart'; // +
// other imports

List<CameraDescription> cameras = <CameraDescription>[]; // +

@pragma('vm:entry-point')
Future<void> main() async { // +-
  // Fetch the available cameras before initializing the app.  // +
  try {  // +
    WidgetsFlutterBinding.ensureInitialized();  // +
    cameras = await availableCameras();  // +
  } on CameraException catch (e) {  // +
    logError(e.code, e.description);  // +
  }  // +
  runApp(CameraApp());  // +-
} // +-

// rest of the code

Expected results:
There should be no active FlutterEngine instances.

(before pressing Back):
Screenshot 2022-05-03 at 2 36 48 PM

(after pressing Back):
Screenshot 2022-05-03 at 2 37 26 PM

Actual results:
There is one active FlutterEngine instance.

(before and after pressing Back):
Screenshot 2022-05-03 at 2 36 48 PM

(after performing steps 4-9 five times):
Screenshot 2022-05-03 at 2 51 49 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions