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
813 stars 475 forks source link

[web]wasm crash issue #1130

Open bymoye opened 1 month ago

bymoye commented 1 month ago

I tried to use the example in the project and compiled it with flutter build web --wasm, and then according to the flutter wasm documentation, used dhttpd '--headers=Cross-Origin-Embedder-Policy=credentialless;Cross-Origin-Opener-Policy=same-origin' to run the web. Then, any operation that calls up the camera will cause the page to freeze (crash). My flutter version:

Flutter 3.22.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b0850beeb2 (4 days ago) • 2024-07-16 21:43:41 -0700
Engine • revision 235db911ba
Tools • Dart 3.4.4 • DevTools 2.34.3

chrome version: 126.0.6478.183

mobile_scanner version: ^5.1.1 Maybe it’s related to skwasm.

navaronbracke commented 1 month ago

I am aware that there are issues with the WASM version.

Do you have a stack trace for the crash? We also had issues with the positioning of the camera preview on web, when running on WASM.

bymoye commented 1 month ago

stack trace

Sorry, I don't have a stack trace. But I found out that if you don't pull up the camera, the page will not crash. However, once the camera is called up (guessing the rendering interface), the page will crash and print in the console c96d18528993aa3ff7287980332a702 And the camera will be turned on (Android phone camera prompt). Through the Performance Monitor in Chrome's DevTools, you can see that the CPU usage is always at 100%.

bymoye commented 1 month ago

I deployed the example to https://test.nazo.run, and perhaps the problem can be reproduced on all devices.

navaronbracke commented 1 month ago

It seems there is an open report for a similar bug in SkWasm at https://github.com/flutter/flutter/issues/150119

Does this reproduce if you switch to the master channel?

bymoye commented 1 month ago

It seems there is an open report for a similar bug in SkWasm at flutter/flutter#150119

Does this reproduce if you switch to the master channel?

I tried switching to the master channel. The page still freezes. But there is no output in my console.

bymoye commented 1 month ago

Sorry, I take back my previous answer. Because I tried to use flutter clean, then flutter pub get and then flutter build web --wasm, which miraculously solved the crash. It seems that the problem lies with flutter? version:

Flutter 3.24.0-1.0.pre.214 • channel master • https://github.com/flutter/flutter.git
Framework • revision c63733310f (2 days ago) • 2024-07-20 19:26:30 -0400
Engine • revision 207f088f73
Tools • Dart 3.6.0 (build 3.6.0-55.0.dev) • DevTools 2.37.1
bymoye commented 1 month ago

The remaining problem is the problem of misalignment.