Skip to content

Creating an empty Vertices object causes an exception on web (canvaskit) #160355

Closed

Description

@gspencergoog

Description

If you attempt to create a Vertices object which doesn't have any vertices in it, the following exception is thrown, which didn't use to be the case. This is currently blocking the Flutter roll, see cl/705912913 for details.

DartError: TypeError: null: type 'Null' is not a subtype of type 'JavaScriptObject'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 307:3  throw_
errors.dart:307
dart-sdk/lib/_internal/js_dev_runtime/private/profile.dart 117:39            _failedAsCheck
profile.dart:117
dart-sdk/lib/_internal/js_shared/lib/rti.dart 1554:3                         _generalAsCheckImplementation
rti.dart:1554
dart-sdk/lib/_internal/js_shared/lib/js_util_patch.dart 110:3                callMethod$
js_util_patch.dart:110
lib/_engine/engine/canvaskit/canvaskit_api.dart 95:8                         CanvasKitExtension.MakeVertices
canvaskit_api.dart:95
lib/_engine/engine/canvaskit/vertices.dart 82:45                             __
vertices.dart:82
lib/_engine/engine/canvaskit/vertices.dart 66:23                             raw
vertices.dart:66
lib/_engine/engine/canvaskit/renderer.dart 124:18                            createVerticesRaw
renderer.dart:124
lib/ui/canvas.dart 45:28                                                     raw
canvas.dart:45
packages/manual_tests/simple_test.dart 7:41                                  main
simple_test.dart:7
web_entrypoint.dart 24:31                                                    <fn>
web_entrypoint.dart:24
lib/ui_web/ui_web/initialization.dart 41:15                                  <fn>
initialization.dart:41
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 622:19          <fn>
async_patch.dart:622
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 647:23          <fn>
async_patch.dart:647
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 593:31          <fn>
async_patch.dart:593
dart-sdk/lib/async/zone.dart 1849:54                                         runUnary
zone.dart:1849
dart-sdk/lib/async/future_impl.dart 208:18                                   handleValue
future_impl.dart:208
dart-sdk/lib/async/future_impl.dart 932:44                                   handleValueCallback
future_impl.dart:932
dart-sdk/lib/async/future_impl.dart 961:13                                   _propagateToListeners
future_impl.dart:961
dart-sdk/lib/async/future_impl.dart 712:5                                    [_completeWithValue]
future_impl.dart:712
dart-sdk/lib/async/future_impl.dart 792:7                                    callback
future_impl.dart:792
dart-sdk/lib/async/schedule_microtask.dart 40:11                             _microtaskLoop
schedule_microtask.dart:40
dart-sdk/lib/async/schedule_microtask.dart 49:5                              _startMicrotaskLoop
schedule_microtask.dart:49
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 186:7           <fn>
async_patch.dart:186

Here's a simple reproduction case:

import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';

void main() {
  final ui.Vertices verts = ui.Vertices.raw(
    VertexMode.triangles,
    Float32List(0),
    indices: Uint16List(0),
    textureCoordinates: Float32List(0),
  );
  print('$verts');

  runApp(const SizedBox.shrink());
}

Activity

  1. added
    c: regressionIt was better in the past than it is now
    engineflutter/engine related. See also e: labels.
    platform-webWeb applications specifically
    c: renderingUI glitches reported at the engine/skia or impeller rendering level
    on Dec 16, 2024
  2. changed the title [-]Creating an empty `Vertices` object causes an exception on web[/-] [+]Creating an empty `Vertices` object causes an exception on web (canvaskit)[/+] on Dec 16, 2024
  3. gspencergoog commented on Dec 16, 2024

    @gspencergoog
    ContributorAuthor

    No longer blocking the roll, because cl/705912913 was submitted.

  4. added
    c: crashStack traces logged to the console
    e: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web
    P1High-priority issues at the top of the work list
    team-webOwned by Web platform team
    triaged-webTriaged by Web platform team
    on Dec 16, 2024
  5. github-actions commented on Feb 14, 2025

    @github-actions

    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.

  6. locked as resolved and limited conversation to collaborators on Feb 14, 2025
  7. filiph commented on May 14, 2025

    @filiph
    Contributor

    I see this was fixed a while ago but I'm seeing the same or very similar error when calling the following constructor on the web:

      final vertices = Vertices(
        VertexMode.triangles,
        positions,  // A list of Offsets. Works well on other platforms.
      );

    The error:

    ======== Exception caught by rendering library =====================================================
    The following _TypeError was thrown during paint():
    TypeError: null: type 'Null' is not a subtype of type 'JavaScriptObject'
    
    The relevant error-causing widget was: 
      RenderGameWidget RenderGameWidget:file:///Users/filiph/.pub-cache/hosted/pub.dev/flame-1.27.0/lib/src/game/game_widget/game_widget.dart:333:36
    When the exception was thrown, this was the stack: 
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 307:3      throw_
    dart-sdk/lib/_internal/js_dev_runtime/private/profile.dart 117:39                _failedAsCheck
    dart-sdk/lib/_internal/js_shared/lib/rti.dart 1554:3                             _generalAsCheckImplementation
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 266:9  callMethod$
    lib/_engine/engine/canvaskit/canvaskit_api.dart 94:8                             CanvasKitExtension.MakeVertices
    lib/_engine/engine/canvaskit/vertices.dart 68:45                                 __
    lib/_engine/engine/canvaskit/vertices.dart 27:23                                 new
    lib/_engine/engine/canvaskit/renderer.dart 105:9                                 createVertices
    lib/ui/canvas.dart 21:28                                                         new
    packages/giant_robot/game/map/smoke/render_smoke.dart 214:20                     renderSmoke
    packages/giant_robot/game/map/game_map_component.dart 171:5                      render
    ...
    

    Flutter version:

    [✓] Flutter (Channel stable, 3.29.3, on macOS 14.7.4 23H420 darwin-arm64,
        locale en-US) [3.3s]
        • Flutter version 3.29.3 on channel stable at
          /Users/filiph/fvm/versions/stable
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ea121f8859 (5 weeks ago), 2025-04-11 19:10:07 +0000
        • Engine revision cf56914b32
        • Dart version 3.7.2
        • DevTools version 2.42.3
    
    [✓] Android toolchain - develop for Android devices (Android SDK version
        35.0.0) [4.1s]
        • Android SDK at /Users/filiph/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • Java binary at: /usr/bin/java
          This JDK was found in the system PATH.
          To manually set the JDK path, use: `flutter config
          --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 19+36-2238)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.2) [3.1s]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16C5032a
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [106ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [!] Android Studio (not installed) [106ms]
        • Android Studio not found; download from
          https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/to/macos-android-setup for detailed
          instructions).
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2025.1.1.1) [105ms]
        • IntelliJ at /Users/filiph/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 85.2.4
        • Dart plugin version 251.25410.28
    
    [✓] VS Code (version 1.92.2) [13ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.84.0
    
    [✓] Connected device (3 available) [6.4s]
        • macOS (desktop)                 • macos                 • darwin-arm64
          • macOS 14.7.4 23H420 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin
          • macOS 14.7.4 23H420 darwin-arm64
        • Chrome (web)                    • chrome                •
          web-javascript • Google Chrome 136.0.7103.93
    
    [✓] Network resources [634ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    

    Should I create a new issue then?

  8. harryterkelsen commented on Jun 4, 2025

    @harryterkelsen
    Contributor

    @filiph Please open another issue if you are still hitting this error, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowc: renderingUI glitches reported at the engine/skia or impeller rendering levele: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webengineflutter/engine related. See also e: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions