Skip to content

Canvas.drawPath fail on WASM when the path contain a polygon with more than 8382 points #182616

Description

@doreille

Steps to reproduce

The code sample work fine when run with
flutter run -d chrome
but crash when run with
flutter run -d chrome --wasm

The chrome console report the RuntimeError error:

Uncaught RuntimeError: memory access out of bounds
    at skwasm.wasm:0xed28
    at skwasm.wasm:0x18e1d
    at skwasm.wasm:0xe381
    at skwasm.wasm:0x476ea
    at skwasm.wasm:0x3d255
    at skwasm.wasm:0x48fbb
    at skwasm.wasm:0xd84b5
    at skwasm.wasm:0xd86ac
    at skwasm.wasm:0x2633bc
    at module0.pathAddPolygon (main.dart.wasm:0x1ade8c)Understand this error
skwasm.wasm:0xb837 Uncaught RuntimeError: memory access out of bounds
    at skwasm.wasm:0xb837
    at skwasm.wasm:0xba80
    at skwasm.wasm:0x717e7
    at skwasm.wasm:0xc156
    at skwasm.wasm:0x102b3a
    at skwasm.wasm:0x80003
    at skwasm.wasm:0x104220
    at skwasm.wasm:0x104202
    at skwasm.wasm:0x260fd1
    at module0.pictureRecorderDispose (main.dart.wasm:0x1a4fd0)

This append on the current stable end main channel.

Google Chrome version is 145.0.7632.75 (Official Build) (64-bit) running on Linux

Expected results

flutter run -d chrome --wasm
on the code sample should display a line and a circle on the web browser page.

Actual results

flutter run -d chrome --wasm
on the code sample display a blank page in the web browser.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return CustomPaint(painter: MyPainter());
  }
}

class MyPainter extends CustomPainter {
  static const int nbPoints = 10000;
  // "flutter run -d chrome --wasm" fail if nbPoints is 8383 or more, but works fine with 8382 or less.
  // "flutter run -d chrome" work fine with any number of points.
  // One solution to work around the issue is to replace path.addPolygon with path.moveTo and path.lineTo.

  @override
  void paint(Canvas canvas, Size size) {
    List<Offset> points = [];
    double step = size.width / nbPoints;
    for (double x = 0; x < size.width; x += step) {
      points.add(Offset(x, size.height / 2));
    }
    final path = Path();
    path.addPolygon(points, false);
    final paint = Paint()
      ..color = Colors.red
      ..style = PaintingStyle.stroke;
    canvas.drawPath(path, paint);

    // draw an oval to easily identify when the rendering engine crashes
    canvas.drawOval(Rect.fromLTWH(0, 0, size.width, size.height), paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false;
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
flutter --verbose run -d chrome --wasm
[  +13 ms] executing: uname -m
[   +2 ms] Exit code 0 from: uname -m
[        ] x86_64
[   +6 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[        ] executing: [/home/doreille/bin/flutter_3.24.0/] git -c log.showSignature=false log HEAD -n 1 --pretty=format:%ad --date=iso
[   +3 ms] Exit code 0 from: git -c log.showSignature=false log HEAD -n 1 --pretty=format:%ad --date=iso
[        ] 2026-02-19 09:10:36 -0500
[  +13 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'FlutterEngineStamp' is not required, skipping update.
[        ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +16 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterEngineStamp' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +13 ms] Skipping pub get: version match.
[  +40 ms] Skipping generating web_plugin_registrant.dart because it is up-to-date.
[  +10 ms] Generating /home/doreille/tmp/path_add_big_polygon_wasm_bug/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[   +1 ms] Skipping generating GeneratedPluginRegistrant.java because it is up-to-date.
[   +1 ms] Skipping generating generated_plugin_registrant.h because it is up-to-date.
[        ] Skipping generating generated_plugin_registrant.cc because it is up-to-date.
[        ] Skipping generating generated_plugins.cmake because it is up-to-date.
[        ] Skipping generating generated_plugin_registrant.h because it is up-to-date.
[        ] Skipping generating generated_plugin_registrant.cc because it is up-to-date.
[        ] Skipping generating generated_plugins.cmake because it is up-to-date.
[        ] Skipping generating GeneratedPluginRegistrant.h because it is up-to-date.
[        ] Skipping generating GeneratedPluginRegistrant.m because it is up-to-date.
[        ] Skipping generating GeneratedPluginRegistrant.swift because it is up-to-date.
[  +77 ms] Launching lib/main.dart on Chrome in debug mode...
[  +20 ms] The --pwa-strategy option is deprecated and will be removed in a future Flutter release.
           For more information, see: https://github.com/flutter/flutter/issues/156910
[  +11 ms] generated_plugin_registrant.dart not found. Skipping.
[        ] Compiling lib/main.dart for the Web...
[   +1 ms] Initializing file store
[   +1 ms] Done initializing file store
[  +17 ms] Skipping target: web_entrypoint
[        ] invalidated build due to missing files: /home/doreille/tmp/path_add_big_polygon_wasm_bug/web/*/index.html, /home/doreille/tmp/path_add_big_polygon_wasm_bug/web/flutter_bootstrap.js
[        ] Skipping target: dart_build
[        ] Skipping target: gen_localizations
[        ] web_templated_files: Starting due to {InvalidatedReasonKind.outputMissing: The following outputs were missing: /home/doreille/tmp/path_add_big_polygon_wasm_bug/build/web/*/index.html,
InvalidatedReasonKind.inputMissing: The following inputs were missing: /home/doreille/tmp/path_add_big_polygon_wasm_bug/web/*/index.html,/home/doreille/tmp/path_add_big_polygon_wasm_bug/web/flutter_bootstrap.js}
[   +1 ms] web_static_assets: Starting due to {InvalidatedReasonKind.outputMissing: The following outputs were missing:
/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/flutter.js,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f
0c7b45c3840c/canvaskit/canvaskit.js,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/canvaskit.js.symbols,/home/doreille/tmp/path_add_big_polygo
n_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/canvaskit.wasm,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/c
hromium/canvaskit.js,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/chromium/canvaskit.js.symbols,/home/doreille/tmp/path_add_big_polygon_wasm
_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/chromium/canvaskit.wasm,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaski
t/skwasm.js,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/skwasm.js.symbols,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutt
er_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/skwasm.wasm,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/skwasm_heavy.js,/home/doreille/
tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/skwasm_heavy.js.symbols,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09ee
a9d0b27f0c7b45c3840c/canvaskit/skwasm_heavy.wasm,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/wimp.js,/home/doreille/tmp/path_add_big_polygo
n_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/wimp.js.symbols,/home/doreille/tmp/path_add_big_polygon_wasm_bug/.dart_tool/flutter_build/82d1ab1b09eea9d0b27f0c7b45c3840c/canvaskit/
wimp.wasm}
[ +136 ms] Skipping target: dart2wasm
[   +1 ms] web_static_assets: Complete
[   +7 ms] web_templated_files: Complete
[  +38 ms] Skipping target: web_release_bundle
[ +102 ms] Skipping target: web_service_worker
[        ] Persisting file store
[   +2 ms] Done persisting file store
[   +6 ms] Compiling lib/main.dart for the Web... (completed in 319ms)
[        ] ✓ Built build/web
[  +23 ms] Launching Chromium (url = http://localhost:32851, headless = false, skipCheck = false, debugPort = null)
[        ] Will use Chromium executable at google-chrome
[  +29 ms] Using Google Chrome 145.0.7632.75 

[  +11 ms] executing: uname -m
[   +3 ms] Exit code 0 from: uname -m
[        ] x86_64
[ +138 ms] [CHROME]: 
[        ] [CHROME]: DevTools listening on ws://127.0.0.1:42857/devtools/browser/69f09d06-6ca8-4cab-b23b-b595fd365d50
[  +59 ms] Flutter run key commands.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).

Flutter Doctor output

Doctor output
flutter doctor -v
[✓] Flutter (Channel main, 3.42.0-1.0.pre-187, on Fedora Linux 43 (Workstation Edition) 6.18.9-200.fc43.x86_64, locale en_GB.UTF-8) [466ms]
    • Flutter version 3.42.0-1.0.pre-187 on channel main at /home/doreille/bin/flutter_3.24.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 06df71c514 (2 hours ago), 2026-02-19 09:10:36 -0500
    • Engine revision 06df71c514
    • Dart version 3.12.0 (build 3.12.0-160.0.dev)
    • DevTools version 2.55.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64

[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [681ms]
    • Android SDK at /home/doreille/Android/Sdk
    • Emulator version 35.6.11.0 (build_id 13610412) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /opt/android-studio/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Chrome - develop for the web [5ms]
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop [99ms]
    • clang version 21.1.8 (Fedora 21.1.8-4.fc43)
    • cmake version 3.28.1
    • ninja version 1.11.1
    • pkg-config version 2.3.0
    ! Unable to access driver information using 'eglinfo'.
      It is likely available from your distribution (e.g.: apt install mesa-utils)

[✓] Connected device (2 available) [66ms]
    • Linux (desktop) • linux  • linux-x64      • Fedora Linux 43 (Workstation Edition) 6.18.9-200.fc43.x86_64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 145.0.7632.75

[✓] Network resources [227ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolee: wasmIssues related to the wasm build of Flutter Web.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions