flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.16k stars 27.46k forks source link

Random CanvasKit crash #67949

Closed luigi-rosso closed 3 years ago

luigi-rosso commented 4 years ago

Repro issues with details for how to trigger it here: https://github.com/luigi-rosso/flutter_canvaskit_crash

Looks like there may be some kind of rare memory leak or bad references left dangling in the CanvasKit renderering backend. Does not happen if I build the same app for MacOS. I randomly get one of these crashes:

[Error]:
RuntimeError: function signature mismatch
js_primitives.dart:47 [Trace]:
RuntimeError: function signature mismatch
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[7219]:0x297335
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[665]:0x12cf4
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[6648]:0x26f6ed
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[2749]:0xd92c9
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[1679]:0x625dc
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[2218]:0xa3df3
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[2737]:0xd87d8
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[5764]:0x2250c1
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[9772]:0x349751
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[1187]:0x342ce
[Error]:
RuntimeError: memory access out of bounds
js_primitives.dart:47 [Trace]:
RuntimeError: memory access out of bounds
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[2370]:0xb1087
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[778]:0x1ad68
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[1041]:0x28c21
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[3755]:0x14dd04
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[3484]:0x12eb11
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[5789]:0x22801d
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[5791]:0x2283dd
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[5792]:0x228a80
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[665]:0x12ad3
    at https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.wasm:wasm-function[6687]:0x275f05

Sometimes it includes a shader compilation error:

══╡  ╞══════════════════════════════════════════════════════════════════════════════════════════════
js_primitives.dart:47 ════════════════════════════════════════════════════════════════════════════════════════════════════
js_primitives.dart:47 Another exception was thrown: Instance of 'ErrorSummary'
canvaskit.js:288 Shader compilation error
S @ canvaskit.js:288
(anonymous) @ canvaskit.wasm:0x3dfead
(anonymous) @ canvaskit.wasm:0x1b9f8b
(anonymous) @ canvaskit.wasm:0x1b9d03
(anonymous) @ canvaskit.wasm:0x9748
(anonymous) @ canvaskit.wasm:0x29057a
(anonymous) @ canvaskit.wasm:0x55dd9
(anonymous) @ canvaskit.wasm:0x464765
(anonymous) @ canvaskit.wasm:0x1e1e26
(anonymous) @ canvaskit.wasm:0x1e36b7
(anonymous) @ canvaskit.wasm:0x46b821
(anonymous) @ canvaskit.wasm:0x46ffb6
(anonymous) @ canvaskit.wasm:0x46a3c4
(anonymous) @ canvaskit.wasm:0x148d5
(anonymous) @ canvaskit.wasm:0x262faa
(anonymous) @ canvaskit.wasm:0x29a78f
(anonymous) @ canvaskit.wasm:0x2a06a5
(anonymous) @ canvaskit.wasm:0xda69d
(anonymous) @ canvaskit.wasm:0x154f4f
(anonymous) @ canvaskit.wasm:0xa3073
(anonymous) @ canvaskit.wasm:0xccb89
(anonymous) @ canvaskit.wasm:0x21ea12
(anonymous) @ canvaskit.wasm:0x21d8b4
(anonymous) @ canvaskit.wasm:0x78d73
Qh @ canvaskit.wasm:0x175d3f
f.dynCall_vii @ canvaskit.js:314
dynCall_vii_574 @ VM3552:4
SkSurface$_flush @ VM4013:8
a.SkSurface.flush @ canvaskit.js:12
flush$0 @ main.dart.js:32795
flush$0$x @ main.dart.js:6527
call$2 @ surface.dart:218
submit$0 @ surface.dart:26
submit$0$z @ main.dart.js:6737
draw$1 @ rasterizer.dart:36
compositeFrame$0 @ window.dart:804
drawFrame$0 @ binding.dart:447
drawFrame$0 @ binding.dart:907
_handlePersistentFrameCallback$1 @ binding.dart:309
eval @ VM4461:3
_invokeFrameCallback$3 @ binding.dart:1117
_invokeFrameCallback$2 @ binding.dart:1109
handleDrawFrame$0 @ binding.dart:1055
_handleDrawFrame$0 @ binding.dart:971

image

Other times it errors without much detail:

══╡  ╞══════════════════════════════════════════════════════════════════════════════════════════════
js_primitives.dart:47 ════════════════════════════════════════════════════════════════════════════════════════════════════

Other WebGL (seemingly related) errors:

[.WebGL-0x7fa7b6853000]GL ERROR :GL_INVALID_VALUE : glTexSubImage2D: bad dimensions.
js_primitives.dart:47 ══╡  ╞══════════════════════════════════════════════════════════════════════════════════════════════
js_primitives.dart:47 ════════════════════════════════════════════════════════════════════════════════════════════════════
:64714/#/:1 [.WebGL-0x7fa7b6853000]GL ERROR :GL_INVALID_VALUE : glTexSubImage2D: bad dimensions.
js_primitives.dart:47 Another exception was thrown: Instance of 'ErrorSummary'

Doctor's visit:

[✓] Flutter (Channel master, 1.23.0-14.0.pre.121, on Mac OS X 10.15.6 19G2021 x86_64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] Connected device (5 available)
tomaash commented 4 years ago

It crashes for me as well when interacting with UI a lot, devtools open. With this stack trace:

══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
js_primitives.dart:30 The following NativeJavaScriptObject object was thrown:
js_primitives.dart:30   RuntimeError: function signature mismatch
js_primitives.dart:30 
js_primitives.dart:30 When the exception was thrown, this was the stack:
js_primitives.dart:30 https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.js 315:77  dynCall_viii
js_primitives.dart:30 https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.js 1:1     dynCall_viii_454
js_primitives.dart:30 https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.js 1:1     SkCanvas$drawPicture
js_primitives.dart:30 lib/_engine/engine/canvaskit/canvas.dart 176:14                  drawPicture
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 394:17                   paint
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 109:14                   paintChildren
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 516:5                    paint
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 109:14                   paintChildren
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 343:5                    paint
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 109:14                   paintChildren
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 343:5                    paint
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 109:14                   paintChildren
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer.dart 343:5                    paint
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer_tree.dart 52:7                paint
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer_tree.dart 76:16               <fn>
js_primitives.dart:30 lib/_engine/engine/profiler.dart 36:18                           timeAction
js_primitives.dart:30 lib/_engine/engine/canvaskit/layer_tree.dart 75:5                raster
js_primitives.dart:30 lib/_engine/engine/canvaskit/rasterizer.dart 34:22               draw
js_primitives.dart:30 lib/_engine/engine/window.dart 726:7                             render
js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 4813:23             compositeFrame
js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 6020:25             drawFrame
js_primitives.dart:30 packages/flutter/src/widgets/widget_span.dart.js 47167:15        drawFrame
js_primitives.dart:30 packages/flutter/src/rendering/layer.dart.js 5980:12             [_handlePersistentFrameCallback]
js_primitives.dart:30 packages/flutter/src/scheduler/binding.dart.js 756:9             [_invokeFrameCallback]
js_primitives.dart:30 packages/flutter/src/scheduler/binding.dart.js 724:37            handleDrawFrame
js_primitives.dart:30 packages/flutter/src/scheduler/binding.dart.js 679:12            [_handleDrawFrame]
js_primitives.dart:30 lib/_engine/engine/window.dart 758:13                            _invoke
js_primitives.dart:30 lib/_engine/engine/window.dart 358:5                             invokeOnDrawFrame
js_primitives.dart:30 lib/_engine/engine.dart 228:18                                   <fn>
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1206:13                             _rootRunUnary
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1100:19                             runUnary
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1005:7                              runUnaryGuarded
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1042:26                             <fn>
js_primitives.dart:30 ════════════════════════════════════════════════════════════════════════════════════════════════════

Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.22.1, on Mac OS X 10.15.7 19H2, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.50.0)

[✓] Connected device (2 available)

• No issues found!
harryterkelsen commented 4 years ago

How often would you say you can get the crash to manifest? I've had no luck so far. If it doesn't crash after 5 or so presses of the refresh button is it better to do a hard refresh and try again or just keep pressing the refresh button?

mjohnsullivan commented 4 years ago

It is rather random; at times we can trigger this almost immediately on page load, tther times it can take longer, but we're seeing it pretty consistently.

luigi-rosso commented 4 years ago

It also manifests more often when the dev tools are open. Btw, we're on Chrome 86.0.4240.80 (Official Build) (x86_64). Oddly seems to occur mostly on Chrome for all of us (don't think anyone has seen it in Safari or Firefox yet).

tomaash commented 4 years ago

@luigi-rosso I second this. Newest chrome, devtools open. Did not crash for me in other browsers yet as well.

harryterkelsen commented 4 years ago

OK. I can get it to crash pretty regularly when I use -d chrome but I have never been able to get it to crash using -d web-server. I also see this crash when running with the latest CanvasKit (0.18.1). I will continue to investigate to find the root cause.

luigi-rosso commented 4 years ago

Thanks @hterkelsen. I've definitely seen it crash by just opening my browser to a CanvasKit site. For example, if I just opened https://preview.rive.app, and after 15 seconds or so it crashed (no dev tools open). It's very random. I then opened the tools to get this report:

image

omatt commented 4 years ago

Using the repro provided, I was able to replicate similar errors on my machine. I used Chrome Version 86.0.4240.80 (Official Build) (x86_64) on MacOS.

repro

Flutter doctor

[✓] Flutter (Channel master, 1.23.0-19.0.pre.26, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-PH)
    • Flutter version 1.23.0-19.0.pre.26
    • Framework revision 33903c17e1 (3 hours ago), 2020-10-14 10:30:10 -0700
    • Engine revision adf5b59485
    • Dart version 2.11.0 (build 2.11.0-217.0.dev)
harryterkelsen commented 4 years ago

Running in -d chrome launches a Chrome instance with --disable-background-timer-throttling, with the comment "// When the DevTools has focus we don't want to slow down the application." I just tried launching the repro app running in -d web-server mode with a Chrome with --disable-background-timer-throttling and the crash reproduced just as easily as with -d chrome. This leads me to believe the underlying cause is a race condition (perhaps something is disposed of before it supposed to be used). I will keep investigating.

TahaTesser commented 4 years ago

For some reason, I see no crash, even on multi tires

Screenshot 2020-10-15 at 7 43 05 PM
flutter doctor -v ```bash [✓] Flutter (Channel master, 1.23.0-19.0.pre.48, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-GB) • Flutter version 1.23.0-19.0.pre.48 at /Users/tahatesser/Code/flutter_master • Framework revision 1133c2e85c (8 hours ago), 2020-10-15 01:57:04 -0400 • Engine revision d2ea378be4 • Dart version 2.11.0 (build 2.11.0-218.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.0.1, Build version 12A7300 • CocoaPods version 1.10.0.rc.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • 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 1.8.0_242-release-1644-b3-6222593) [✓] VS Code (version 1.50.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.15.0 [✓] Connected device (4 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 10 (API 29) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.7 19H2 darwin-x64 • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.80 • No issues found! ```
omatt commented 4 years ago

I've updated my Flutter master channel build from 1.23.0-19.0.pre.26 to 1.23.0-19.0.pre.50 and I'm also unable to replicate the crash again.

[✓] Flutter (Channel master, 1.23.0-19.0.pre.50, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-PH)
    • Flutter version 1.23.0-19.0.pre.50 at /Users/{USER}/Downloads/flutter
    • Framework revision 46ff57d6f1 (39 minutes ago), 2020-10-15 08:04:59 -0700
    • Engine revision 11d756a62e
    • Dart version 2.11.0 (build 2.11.0-207.0.dev)
luigi-rosso commented 4 years ago

I'll try on the latest again today, it's really insidious in that it can go for a while without happening and then happen multiple times in succession. I tested for hours yesterday afternoon and it didn't happen, then it happened five times in a row. I think @hterkelsen's sense of it being some race condition that will cause the CanvasKit backend to use an invalid/previously-disposed reference really seems plausible.

luigi-rosso commented 4 years ago

I reproduced it immediately with 1.23.0-19.0.pre.53 image

omatt commented 4 years ago

Can confirm on 1.23.0-19.0.pre.53. It had me try refreshing the browser directly and a clicking on the the refresh button alternately for the page to crash.

harryterkelsen commented 4 years ago

This seems to be an issue affecting multiple WebAssembly libraries (not just CanvasKit). https://bugs.chromium.org/p/chromium/issues/detail?id=1138947

Unfortunately I don't think there's anything we can do besides wait for a fix in Chrome...

ajklein commented 4 years ago

It seems that the root cause may be https://crbug.com/v8/10957. If you can reproduce reliably, can you try with the latest canary version (88.0.4293.0)?

luigi-rosso commented 4 years ago

That makes a lot of sense, thanks for tracking it down. We'll try canary and report back.

harryterkelsen commented 4 years ago

I was unable to repro with Canary while being able to consistently repro on Chrome 86.

tomaash commented 4 years ago

It also works for me on Canary so far. Thanks! :+1:

luigi-rosso commented 4 years ago

Same, looking good here so far!

rydmike commented 4 years ago

Similar or potentially same issue here

I have noticed that our CanvasKit builds just randomly blows up too. It builds and runs fine on device/desktop, no errors. The project uses features that do not work on DomCanvas, like flutter_svg and some other stuff too, but I commented them out to be able to build and try it on DomCanvas as well, it runs fine then, but still randomly blows up with CanvasKit, so it is not the SVGs. Tried various flutter versions, same issue.

There are still some package dependencies that could be another potential source of the issue, so I wont know for sure until I make sample that bombs without them and is more simple, as a reproducible case.

The errors I get when the CanvasKit builds crashes are similar to the errors reported here though, here is example crash report. Sometimes it is much longer, depends on when and where it happens, seems kind of random.

For a more detailed help message, press "h". To quit, press "q".
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY 
The following NativeJavaScriptObject object was thrown during a scheduler callback:
  RuntimeError: function signature mismatch

When the exception was thrown, this was the stack:
https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.js 314:508                                                 dynCall_vii
https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.js 161:236                                                 dynCall_vii_574
https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.js 162:403                                                 SkSurface$_flush
https://unpkg.com/canvaskit-wasm@0.17.3/bin/canvaskit.js 12:136                                                  flush
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/surface.dart 218:14    flush
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/surface.dart 199:5     [_presentSurface]
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/surface.dart 74:14     <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/surface.dart 26:26     submit
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/rasterizer.dart 36:12  draw
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/window.dart 779:7                render
packages/flutter/src/rendering/view.dart 234:15                                                                  compositeFrame
packages/flutter/src/rendering/binding.dart 447:18                                                               drawFrame
packages/flutter/src/widgets/binding.dart 907:13                                                                 drawFrame
packages/flutter/src/rendering/binding.dart 309:5                                                                [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1117:15                                                              [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1055:9                                                               handleDrawFrame
packages/flutter/src/scheduler/binding.dart 971:5                                                                [_handleDrawFrame]
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/window.dart 812:13               _invoke
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/window.dart 396:5                invokeOnDrawFrame
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine.dart 235:18                      <fn>

cc: @mariamhas FYI, we run into this with TALO as well. I keep, when it comes to UI features, a pretty similar stack of tech in the Flexfold demo https://rydmike.github.io/demoflexfold/#/ and its builds now crash as well. Our builds for Web are pretty broken as we totally depend on CanvasKit for it to run on Web at all, but that's fine, we just build and test on Desktop for now, all is fine there.


I will follow up with more details here later or make a separate issue if it is not related to this case. This was basically just a "potentially me too" notice so far.

rydmike commented 4 years ago

Strange and elusive crash issue, this one is...

This issue seems very strange, I have a simpler sample repo that use some of the similar patterns that is used in the above larger app where I ran into it.

The strange part is that sometimes it crashes very quickly, other times not. So far I have been unable to figure out what I need to do to repeat it consistently with my sample repo. I was just about to say that on this build it refuses to crash at all.

Then suddenly without even doing anything, while I'm typing this, the sample app was just sitting there and it throws this into the web console and terminal too without anybody touching it.

js_primitives.dart:30 ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
js_primitives.dart:30 The following NativeJavaScriptObject object was thrown during a scheduler callback:
js_primitives.dart:30   RuntimeError: function signature mismatch
js_primitives.dart:30 
js_primitives.dart:30 When the exception was thrown, this was the stack:
js_primitives.dart:30 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 269:156                                                 dynCall_viiiiifiii
js_primitives.dart:30 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 1:1                                                     dynCall_viiiiifiii_456
js_primitives.dart:30 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 1:1                                                     SkCanvas$_drawShadow
js_primitives.dart:30 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 55:344                                                  drawShadow
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/util.dart 65:11        drawSkShadow
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/canvas.dart 200:5      drawShadow
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 527:11      drawShadow
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 483:7       paint
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 109:14      paintChildren
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 343:5       paint
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 109:14      paintChildren
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 199:5       paint
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 109:14      paintChildren
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 343:5       paint
js_primitives.dart:30 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 109:14      paintChildren

Just for info, the sample app looks like this:

image

I will tinker with it a bit more and see if I can get it to crash a bit more consistently. Even if I can't I will just post a link the Gist source for it, maybe somebody else can get it to crash on demand and not just randomly.


Edit: Since it was mentioned above that it has been seen only (mostly) on Chrome, I just wanted to add that on Windows I see this crash on Edge too, but yeah it uses the same engine so I guess that could explain that.

luigi-rosso commented 4 years ago

@rydmike this does seem like the same issue. The Chrome team has fixed the issue, it'll be in an updated 86 build in the near future (if I can read the chromium bug reports linked above correctly). In the meantime, the fix is already in the latest Chrome Canary build. You can grab that here for testing: https://www.google.com/chrome/canary/

rydmike commented 4 years ago

@luigi-rosso Thanks for the info. I will try it, also with the app where I found this issue.

With the app where I first saw this issue it was occurring pretty much straight away, also in Microsoft Edge browser, whatever version Windows 10 pushes, did not check.

In my issue playground app it does not happen as often, it can even be tricky to trigger it, sometimes it just happens immediately and sometimes not all, not matter how much I tinker with the switches, toggle theme mode, scroll, resize... then suddenly it can just blow up on its own, weird stuff really.

Example

What it looks like when it does blow up: image

:58355/dart_sdk.js:26740 ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
:58355/dart_sdk.js:26740 The following NativeJavaScriptObject object was thrown during a scheduler callback:
:58355/dart_sdk.js:26740   RuntimeError: invalid index into function table
:58355/dart_sdk.js:26740 
:58355/dart_sdk.js:26740 When the exception was thrown, this was the stack:
:58355/dart_sdk.js:26740 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 269:156                                                 dynCall_viiiiifiii
:58355/dart_sdk.js:26740 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 170:236                                                 dynCall_viiiiifiii_456
:58355/dart_sdk.js:26740 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 171:403                                                 SkCanvas$_drawShadow
:58355/dart_sdk.js:26740 https://unpkg.com/canvaskit-wasm@0.18.1/bin/canvaskit.js 55:344                                                  drawShadow
:58355/dart_sdk.js:26740 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/util.dart 65:11        drawSkShadow
:58355/dart_sdk.js:26740 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/canvas.dart 200:5      drawShadow
:58355/dart_sdk.js:26740 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 527:11      drawShadow
:58355/dart_sdk.js:26740 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 483:7       paint
:58355/dart_sdk.js:26740 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 109:14      paintChildren
:58355/dart_sdk.js:26740 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/canvaskit/layer.dart 343:5       paint
:58355/dart_sdk.js:26740 C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engin

Issue repo

Here is a link to the source code for the repo I tried to use to reproduce the issue with: https://gist.github.com/rydmike/3a0818223933d459f4ce2760ddd92661

My test debug builds were made with: flutter run -d chrome --debug --dart-define=FLUTTER_WEB_USE_SKIA=true --dart-define=FLUTTER_WEB_USE_EXPERIMENTAL_CANVAS_TEXT=true

Using version Channel master, 1.23.0-19.0.pre.92 but it happened on pretty much any version and channel that could make a CanvasKit Web build.

Question

This Flutter Web tech demo app was built with CanvasKit, and hosted on GitHub Oct 12, 2020: https://rydmike.github.io/demoflexfold/#/

It runs fine and works with my currently installed versions of Chrome, Edge and Firefox (a bit slower on Firefox).

If this issue would be related to CanvasKit in the Chrome browser, should it not blow up to?

It does not. This demo version was built and pushed live Oct 12, 2020, built with whatever Flutter master version was was available then. (https://github.com/rydmike/rydmike.github.io/commit/e5e5c8704014a0a5dd7017442fbd6a16722d9a4a)

Pardon my ignorance, but is there somewhere I can read up what actually happens when you make a Flutter CanvasKit build?

Because the issue with the recent builds being related to Chrome web browser version just does not seem to compute to me. For it to make sense and for the above live Flutter CanvasKit tech demo app to not be broken as well, the next things would have to happen:

Is the Flutter CanvasKit build embedding the CanvasKit engine somehow into the built app? Somehow that does not really make sense to me, but in case it does do that, it would only make sense that this embedded CanvasKit engine is taken from your Chrome install available during the Flutter build, otherwise why would a new Chrome version fix it. That way in theory the 6 days old one could maybe have had one that works, while the recent builds get a never version that are broken and I can still run a published app that was built with a slightly older Chrome installed.

Sound strange, but only that rather exotic combo would logically explain to me why the above demo is not broken as well now when I try to run it with the same Chrome version that crashes with the above sample builds. If I try to build a newer version of the above shown Flutter Web tech demo app it now crashes all the time as well.

OK this was jus me trying to reason about what I am observing. Perhaps someone with more insights into how things really work when you make release build of a Flutter CanvasKit Web app, can shed some more light on it.


I guess I should download the canary version and see how it affects the above Flutter tech demo app where this issue occurs all the time as well if I try to build it after the install. I'll report back on my findings...

rydmike commented 4 years ago

Makes more sense now

After a closer and longer look at the published version: https://rydmike.github.io/demoflexfold/#/

I noticed that it has started to crash as well. It did not do so at quick first glance, but I kept it open for a while and it imploded as well. After that it I could get it to do it regularly.

Well OK then, now I can agree that Chrome is busted. Edge is affected too, because I can repeat the issue on Edge.

I download the Chrome Canary version. It has not blown up yet, not even with the more complex tech demo app, although I have not re-enabled all the fancy features that I took away from it to be able to try it on DomCanvas. I will do that as well to give it proper stress test and leave open a CanvasKit built version for a while. It uses timers that keeps crossfading 100's of SVG images forever, its a pretty good stress test.

Here is pic of the reduced version. Canary on the left and latest official release on the right, which blew up pretty quickly, Canary still running OK:

image


About the...

canvaskit.js:15 WARNING: Too many active WebGL contexts. Oldest context will be lost.

...shown on both. Should we be concerned about that? I see that on pretty much any Web CanvasKit build. An easy way to see it is just resizing the browser window on any app for a while, quickly.

rydmike commented 4 years ago

A more demanding test

Chrome Canary in yellow on the left and official release on the right, it was in blue, but it blew up in such a funky way before I could start recording it, but hey the SVGs are still animating in their twisted small view 😄

ChromeBug

I'll keep Canary running and see if it remains stable.

yjbanov commented 3 years ago

Dropped to P4 since this happens only when DevTools is open, and we're just waiting for a Chrome fix.

ajklein commented 3 years ago

This should be fixed on the Chrome side, in both Chrome 86 (old stable) and 87 (current stable).

rydmike commented 3 years ago

I rebuilt the example issue repo above: https://gist.github.com/rydmike/3a0818223933d459f4ce2760ddd92661 that pretty much was crashing all the time before in my tests.

I rebuilt it with Flutter: beta: 1.24.0-10.2.pre dev: 1.25.0-4.0.pre master: 1.25.0-5.0.pre.38

in both debug and release mode for all above channels+versions. I opened the Chrome dev tools, played around with the demo app.

I did not observe any crash in any of the 6 builds.

I used web builds with skia and canvas text enabled.

Chrome version was: Version 86.0.4240.198 (Official Build) (64-bit)

Looks like the Chrome fix is working OK.


Sidenote The SKIA web builds felt a bit more sluggish than I recalled them being with this test app. Beta felt slowest of the bunch.

yjbanov commented 3 years ago

Chrome 87 stable is out. Should we close this?

rydmike commented 3 years ago

Yes, I think it can be closed 👍

TahaTesser commented 3 years ago

Thank you so much for confirming @rydmike Given your last message I feel safe to close this issue, if you disagree please write in the comments and I will reopen it. Thank you

yaizudamashii commented 3 years ago

I am experiencing this issue when adding shadows to Text widget, then placing onto canvas on beta 2.0.1. I haven't minimally isolated the code, but when I do, I will post the code here.

EDIT: The issue does not happen with one or two shadows, but happens with three shadows and resizing the text, and four shadows and simply placing the text.

rydmike commented 3 years ago

@yaizudamashii Sounds interesting, but not fun.

Since this issue is closed, I recommend that you create a new issue, with your reproducible code sample. Sure by all means, put a link to this case as reference if you think it might be related to it. Maybe tag @TahaTesser in it that triaged this issue before, then he can confirm it and add proper tags to the issue.

rshrc commented 3 years ago

@TahaTesser @yaizudamashii was a new issue filed? I'll file one if that is not the case. In a small gist, the browser console blows up on random scenarious, with the same sort of errors posted wayyy up in this conversation.

Some system/flutter configs that I am using are

flutter run -d chrome --release (Does not seem to break in the debug mode)

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.18363.1379], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.5)
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.53.2)
[√] Connected device (3 available)

• No issues found!
yaizudamashii commented 3 years ago

@rshrc No, I have been filed, I've been lazy. You can go ahead and file one.

kevin4dhd commented 3 years ago

The same error, there is not a day that I find a new error in flutter, disappointing.

ciriousjoker commented 3 years ago

For me, a similar issue appears when moving Chrome to a different monitor with a different resolution. Animation plays fine on first monitor, page completely freezes with "memory access out of bounds" on the second monitor.

mariamhas commented 3 years ago

Since this issue is closed, please file a new issue with repro steps/sample code. Thanks!

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.