Open xjyribro opened 9 months ago
Not sure if this is related but I also occasionally get the same error in Android Studio. It is inconsistent and I have not been able to isolate the problem:
RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
canvaskit/chromium/canvaskit.js 93:75 Ea
canvaskit/chromium/canvaskit.js 168:377 k
canvaskit/chromium/canvaskit.js 115:52 <fn>
canvaskit/chromium/canvaskit.js 105:260 <computed>
canvaskit/chromium/canvaskit.js 33:9 g
canvaskit/chromium/canvaskit.js 43:340 readPixels // <---- seems like it is the same error
lib/_engine/engine/canvaskit/canvaskit_api.dart 1165:7 SkImageExtension.readPixels
lib/_engine/engine/canvaskit/picture.dart 108:38 toImageSync
packages/flame_tiled_utils/src/image_batch_compiler.dart 39:26 compileMapLayer
Hi @xjyribro, you are using an older version of flutter. Kindly upgrade to the latest version of flutter (3.19.2) to see if you still experience this issue. If you do, please provide a complete runnable reproducible code sample so that we can investigate this issue.
Thank you
Hi @danagbemava-nc
I have upgraded to Flutter (3.19.2). The error is still there. This is the link to find the deployed Flutter web demo: https://xjyribro.github.io/xjyribro.gomiland.io/. It works with Desktop Chrome but not mobile.
This is the link to the full repo: https://github.com/xjyribro/gomiland. Thanks for the assistance!
Hi @xjyribro, the repo provided is huge, could you provide one with only the relevant code required to reproduce the bug so that it can be properly investigated? Can you also try reaching out to the flame team to see if they can offer any assistance?
PS: If you run the app in profile mode, you might get a clearer stacktrace than the one you get in release mode.
Thank you
Ok I will work on a minimum repo. In the meantime, I ran the app in profile mode. The issue is coming from a package called flame_tiled_utils.
This is the better stacktrack:
at Object.throw_ [as throw] (errors.dart:297:3)
at _engine.SurfaceCanvas.__.drawAtlas (canvas.dart:451:5)
at sprite_batch.SpriteBatch.new.render (sprite_batch.dart:378:13)
at orthogonal_tile_layer.OrthogonalTileLayer.new.render (tile_layer.dart:145:16)
at renderable_tile_map.RenderableTiledMap.new.render (renderable_tile_map.dart:414:12)
at image_batch_compiler.ImageBatchCompiler.new.compileMapLayer (image_batch_compiler.dart:29:12)
@danagbemava-nc
I created the minimal repohere: https://github.com/xjyribro/tiled_test. Instructions in the readme file. Instructions in the readme file.
I also opened an issue with the Flame package also. https://github.com/flame-engine/flame/issues/3067
Hi @xjyribro, is this the error you get with the minimal repro?
errors.dart:297 Uncaught (in promise) Error: TypeError: null: type 'Null' is not a subtype of type 'JavaScriptObject'
at Object.throw_ [as throw] (errors.dart:297:3)
at Object._failedAsCheck (rti.dart:1385:3)
at dart_rti.Rti.new._generalAsCheckImplementation (rti.dart:1363:3)
at _engine.CkPicture.new.toImageSync (picture.dart:100:47)
at image_batch_compiler.ImageBatchCompiler.new.compileMapLayer (image_batch_compiler.dart:39:26)
at game.GomilandWorld.new._loadMap (game.dart:53:33)
at _loadMap.next (<anonymous>)
at runBody (async_patch.dart:84:54)
at Object._async [as async] (async_patch.dart:127:5)
at [_loadMap] (game.dart:39:24)
at game.GomilandWorld.new.onLoad$ (game.dart:80:11)
at onLoad$.next (<anonymous>)
at async_patch.dart:45:50
at _RootZone.runUnary (zone.dart:1661:54)
at _FutureListener.thenAwait.handleValue (future_impl.dart:162:18)
at handleValueCallback (future_impl.dart:838:44)
at _Future._propagateToListeners (future_impl.dart:867:13)
at [_completeWithValue] (future_impl.dart:643:5)
at future.dart:524:22
at _RootZone.runUnary (zone.dart:1661:54)
at _FutureListener.then.handleValue (future_impl.dart:162:18)
at handleValueCallback (future_impl.dart:838:44)
at _Future._propagateToListeners (future_impl.dart:867:13)
at [_completeWithValue] (future_impl.dart:643:5)
at async._AsyncCallbackEntry.new.callback (future_impl.dart:713:7)
at Object._microtaskLoop (schedule_microtask.dart:40:11)
at _startMicrotaskLoop (schedule_microtask.dart:49:5)
at async_patch.dart:181:7
No this this is my error:
Uncaught (in promise) Error: UnimplementedError
at Object.throw_ [as throw] (errors.dart:297:3)
at _engine.SurfaceCanvas.__.drawAtlas (canvas.dart:451:5)
at sprite_batch.SpriteBatch.new.render (sprite_batch.dart:378:13)
at orthogonal_tile_layer.OrthogonalTileLayer.new.render (tile_layer.dart:145:16)
at renderable_tile_map.RenderableTiledMap.new.render (renderable_tile_map.dart:414:12)
at image_batch_compiler.ImageBatchCompiler.new.compileMapLayer (image_batch_compiler.dart:29:12)
@xjyribro, did you run with the --web-renderer canvaskit
flag? If not, I think you might be using the html renderer and I don't think this is supported yet with that renderer.
@danagbemava-nc
Ah ok with the flag --web-renderer canvaskit
. I get the same error as you.
errors.dart:297 Uncaught (in promise) Error: TypeError: null: type 'Null' is not a subtype of type 'JavaScriptObject'
at Object.throw_ [as throw] (errors.dart:297:3)
at Object._failedAsCheck (rti.dart:1385:3)
at dart_rti.Rti.new._generalAsCheckImplementation (rti.dart:1363:3)
at _engine.CkPicture.new.toImageSync (picture.dart:100:47)
at image_batch_compiler.ImageBatchCompiler.new.compileMapLayer (image_batch_compiler.dart:39:26)
Thanks for the update.
Reproducible using the reduced sample in https://github.com/xjyribro/tiled_test
On Android, the crash occurs at this line https://github.com/flutter/engine/blob/6e4562338cf38cad7ee1de0dbd1040b5a60a876e/lib/web_ui/lib/src/engine/canvaskit/picture.dart#L108
For iOS, the page reloaded several times and crashed when I tried to load the tile map and there wasn't any errors to be collected.
Labeling for further investigation.
errors.dart:296 Uncaught (in promise) Error: TypeError: null: type 'Null' is not a subtype of type 'JavaScriptObject'
at Object.throw_ [as throw] (errors.dart:296:3)
at Object._failedAsCheck (rti.dart:1388:3)
at dart_rti.Rti.new._generalAsCheckImplementation (rti.dart:1366:3)
at _engine.CkPicture.new.toImageSync (picture.dart:100:47)
at image_batch_compiler.ImageBatchCompiler.new.compileMapLayer (image_batch_compiler.dart:39:26)
at game.GomilandWorld.new._loadMap (game.dart:53:33)
at _loadMap.next (<anonymous>)
at runBody (async_patch.dart:84:54)
at Object._async [as async] (async_patch.dart:127:5)
at [_loadMap] (game.dart:39:24)
at game.GomilandWorld.new.onLoad$ (game.dart:80:11)
at onLoad$.next (<anonymous>)
at async_patch.dart:45:50
at _RootZone.runUnary (zone.dart:1661:54)
at _FutureListener.thenAwait.handleValue (future_impl.dart:163:18)
at handleValueCallback (future_impl.dart:847:44)
at _Future._propagateToListeners (future_impl.dart:876:13)
at [_completeWithValue] (future_impl.dart:652:5)
at future.dart:532:22
at _RootZone.runUnary (zone.dart:1661:54)
at _FutureListener.then.handleValue (future_impl.dart:163:18)
at handleValueCallback (future_impl.dart:847:44)
at _Future._propagateToListeners (future_impl.dart:876:13)
at [_completeWithValue] (future_impl.dart:652:5)
at async._AsyncCallbackEntry.new.callback (future_impl.dart:722:7)
at Object._microtaskLoop (schedule_microtask.dart:40:11)
at _startMicrotaskLoop (schedule_microtask.dart:49:5)
at async_patch.dart:181:7
It looks like ckSurface.surface.makeImageSnapshot()
unexpectedly returns null. We're calling CanvasKit.makeImageSnapshot
through JS interop, but JS interop cannot guarantee soundness and can still return null even if we expect a non-null value. This needs to be investigated further.
any updates on the issue?
Any updates? Did someone find the solution or not? @BonDizard what did you do? did you find anything?
When using Flame Flutter, I also got the above error.
However, this error only appears when using web Chrome directly on mobile devices. I have absolutely no errors when using Web Chrome on my computer, including Web Chrome desktop developer tools with a phone screen.
main.dart.js:12731 Error adding components: Unsupported operation: toImageSync is not supported on the HTML backend. Use drawPicture instead, or toImage.
at Object.d (main.dart.js:4317:18)
at qq.qW (main.dart.js:16651:17)
at jw.ld (main.dart.js:30415:12)
at jm.N7 ( main.dart.js:38091:5)
at Ez.$1 (main.dart.js:38006:3)
at e0.G (main.dart.js:26510:30)
at hJ.fD (main.dart.js:37915:15)
at GH.$1 (main.dart.js:29872:24)
at qh.lk (main.dart.js:30016:3)
at rY.fD (main.dart.js:29850:3)
I have not found a solution yet, still in the process of being investigated. I comment here to get notified if the community has an answer.
Steps to reproduce
flutter build web
orflutter build web --web-renderer canvaskit
Expected results
Should be able to play game on both Desktop and Mobile.
Actual results
Flutter app hangs when trying to load a Flame game.
Code sample
Code sample
I am loading a GameWidget from the Flame package. I suspect the tilemap or sprite image rendering has a problem on mobile browsers. ```dart class GameWidgetWrapper extends StatelessWidget { final bool loadFromSave; const GameWidgetWrapper({super.key, required this.loadFromSave}); @override Widget build(BuildContext context) { return Center( child: ClipRect( child: SizedBox( width: gameWidth, height: gameHeight, child: GameWidget( game: GomilandGame( gameStateBloc: context.readScreenshots or Video
Screenshots / Video demonstration
![error](https://github.com/flutter/flutter/assets/62128387/9484d534-24b9-47a9-817c-e312f9435744)Logs
Logs
```console Uncaught TypeError: Cannot read properties of null (reading 'readPixels') at Pg.E1 (main.dart.js:34438:5) at E_.IF (main.dart.js:53394:5) at main.dart.js:94147:16 at aGG.a (main.dart.js:4468:62) at aGG.$2 (main.dart.js:41098:14) at Object.o (main.dart.js:4454:10) at RM.afa (main.dart.js:94157:10) at RM.uV (main.dart.js:94138:19) at main.dart.js:94031:14 at aGG.a (main.dart.js:4468:62) ```Flutter Doctor output
Doctor output
```console [√] Flutter (Channel stable, 3.16.5, on Microsoft Windows [Version 10.0.19045.4046], locale en-GB) • Flutter version 3.16.5 on channel stable at C:\Users\limch\Documents\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 78666c8dc5 (2 months ago), 2023-12-19 16:14:14 -0800 • Engine revision 3f3e560236 • Dart version 3.2.3 • DevTools version 2.28.4 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at C:\Users\limch\AppData\Local\Android\Sdk • Platform android-33, build-tools 33.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.8) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools • Visual Studio Build Tools 2019 version 16.11.32002.261 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) [√] IntelliJ IDEA Ultimate Edition (version 2023.2) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2023.2 • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart [√] VS Code (version 1.86.2) • VS Code at C:\Users\limch\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.82.0 [√] Connected device (4 available) • M2010J19SG (mobile) • 8bbb5f8a0421 • android-arm64 • Android 12 (API 31) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4046] • Chrome (web) • chrome • web-javascript • Google Chrome 122.0.6261.70 • Edge (web) • edge • web-javascript • Microsoft Edge 122.0.2365.52 [√] Network resources • All expected network resources are available. • No issues found! ```