juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
804 stars 471 forks source link

Better support for Hot Reload #773

Open laterdayi opened 10 months ago

laterdayi commented 10 months ago

Using Hot Reload on either iOS or Android on view with camera causes MobileScanner: Called start() while already started! error.

Repro steps:

build example app to device open any camera screen do Hot Reload

This problem still exists in the latest version

navaronbracke commented 9 months ago

This does not reproduce on Android/iOS with hot reload/hot restart on version 3.5.1 for the example app.

laterdayi commented 9 months ago

I use the latest versions of flutter and mobile_scanner, and this issue still occurs when hot reloading, which I will try to repeat later

navaronbracke commented 5 months ago

@laterdayi Does this reproduce on version 5.0.0-beta.1 ? We fixed the lifecycle management issues in that release, so I think that solves this bug.

y-az commented 5 months ago

Hi @navaronbracke I'm on version 5.0.0-beta.1 and I'm running into this error

navaronbracke commented 5 months ago

Okay, then I think I know what is happening. The package will have to listen to hot reload events to prevent this issue from happening.

We might be able to leverage https://api.flutter.dev/flutter/widgets/State/reassemble.html

EArminjon commented 3 months ago

(maybe this topic can help once fixed : https://github.com/flutter/flutter/issues/10437)