Skip to content

bug: a few hot restarts cause a canvaskit failure #140684

Closed

Description

@yeikel16

Steps to reproduce

  1. Open example in VSCode, chose web platform
  2. Set a breakpoint on line that calls runApp
  3. Debug
  4. Then the breakpoint is hit, click hot restart a few times

Issues related:

#90236

Expected results

Not error when make hot reload

Actual results

The app is freezed and show a error in console. The dialog of "Flutter: Hot reloading" not close.

Captura de pantalla 2023-12-27 a la(s) 10 25 48 p m

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 MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Material App Bar'),
        ),
        body: const Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

Logs

Logs
Launching lib/main.dart on Chrome in debug mode...
This app is linked to the debug service: ws://127.0.0.1:64538/SH-yEsqGG2I=/ws
Debug service listening on ws://127.0.0.1:64538/SH-yEsqGG2I=/ws
Connecting to VM Service at ws://127.0.0.1:64538/SH-yEsqGG2I=/ws
Restarted application in 1,307ms.
Error: Expected a wrapped Dart object, but got a JS object or a wrapped Dart object from a separate runtime instead.
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:3       throw_
dart-sdk/lib/_internal/js_shared/lib/js_interop_patch.dart 89:7                   JSBoxedDartObjectToObject.get$35toDart
lib/_engine/engine/canvaskit/native_memory.dart 24:46                             <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 574:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 579:39  dcall

In some case show this error to

Restarted application in 2,200ms.
Error: Expected a wrapped Dart object, but got a JS object or a wrapped Dart object from a separate runtime instead.
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:3       throw_
dart-sdk/lib/_internal/js_shared/lib/js_interop_patch.dart 89:7                   JSBoxedDartObjectToObject.get$35toDart
lib/_engine/engine/canvaskit/native_memory.dart 24:46                             <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 574:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 579:39  dcall

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.2 23C64 darwin-arm64, locale es-US)
    • Flutter version 3.16.5 on channel stable at /Users/yeikel/fvm/versions/3.16.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (hace 8 días), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/yeikel/Library/Android/sdk/
    • Platform android-34, build-tools 33.0.1
    • ANDROID_HOME = /Users/yeikel/Library/Android/sdk/
    • Java binary at: /Applications/Android Studio 2.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio 2020.3.1.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 11.0.10+0-b96-7249189)

[✓] Android Studio (version 2021.3)
    • 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 11.0.13+0-b1751.21-8125866)

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio 2.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 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.84.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.78.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.2 23C64 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 120.0.6099.129

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

Activity

  1. danagbemava-nc commented on Dec 29, 2023

    @danagbemava-nc
    Member

    Reproducible using the code sample and steps outlined above.

    Labeling for further investigation

    Error: Expected a wrapped Dart object, but got a JS object or a wrapped Dart object from a separate runtime instead.
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3       throw_
    dart-sdk/lib/_internal/js_shared/lib/js_interop_patch.dart 93:7                   JSBoxedDartObjectToObject.get$35toDart
    lib/_engine/engine/canvaskit/native_memory.dart 24:46                             <fn>
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 550:37  _checkAndCall
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 555:39  dcall
    Application finished.
    
    flutter doctor -v
    [!] Flutter (Channel stable, 3.16.5, on macOS 14.1.2 23B92 darwin-arm64, locale en-GB)
        • Flutter version 3.16.5 on channel stable at /Users/nexus/dev/sdks/flutter
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 78666c8dc5 (9 days ago), 2023-12-19 16:14:14 -0800
        • Engine revision 3f3e560236
        • Dart version 3.2.3
        • DevTools version 2.28.4
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0-rc1
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0)
        • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
        • Build 15A240d
        • CocoaPods version 1.14.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Users/nexus/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 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 76.3.4
        • Dart plugin version 232.10072.19
    
    [✓] VS Code (version 1.85.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.80.0
    
    [✓] Connected device (4 available)
        • Nexus (mobile)       • 00008020-001875E83A38002E • ios            • iOS 17.2.1 21C66
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 17.2 21C62
        • macOS (desktop)      • macos                     • darwin-arm64   • macOS 14.1.2 23B92 darwin-arm64
        • Chrome (web)         • chrome                    • web-javascript • Google Chrome 120.0.6099.129
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel master, 3.18.0-18.0.pre.44, on macOS 14.1.2 23B92 darwin-arm64, locale en-GB)
        • Flutter version 3.18.0-18.0.pre.44 on channel master at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 420f18be76 (4 hours ago), 2023-12-29 13:45:36 +0800
        • Engine revision 7a7ddc53cd
        • Dart version 3.3.0 (build 3.3.0-270.0.dev)
        • DevTools version 2.31.0-dev.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0-rc1
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0)
        • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
        • Build 15A240d
        • CocoaPods version 1.14.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Users/nexus/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 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 76.3.4
        • Dart plugin version 232.10072.19
    
    [✓] VS Code (version 1.85.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.80.0
    
    [✓] Connected device (4 available)
        • Nexus (mobile)       • 00008020-001875E83A38002E • ios            • iOS 17.2.1 21C66
        • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 17.2 21C62
        • macOS (desktop)      • macos                     • darwin-arm64   • macOS 14.1.2 23B92 darwin-arm64
        • Chrome (web)         • chrome                    • web-javascript • Google Chrome 120.0.6099.129
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
    
  2. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    engineflutter/engine related. See also e: labels.
    t: hot reloadReloading code during "flutter run"
    e: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-webOwned by Web platform team
    and removed
    in triagePresently being triaged by the triage team
    on Dec 29, 2023
  3. ericwindmill commented on Feb 20, 2024

    @ericwindmill

    I'm seeing something similar using Intellij, Flutter 3.14, up-to-date Intellij plugin (231.9411).

    I'm not using a debugger or running in debug mode. After 2-3 hot restarts, I start seeing an error.

    Assertion failed: org-dartlang-sdk:///lib/_engine/engine/window.dart:91:12
    !isDisposed
    "Trying to render a disposed EngineFlutterView."
    
    When the exception was thrown, this was the stack: 
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3       throw_
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 38:3        assertFailed
    lib/_engine/engine/window.dart 91:13                                              render
    packages/flutter/src/rendering/view.dart 256:7                                    compositeFrame
    packages/flutter/src/rendering/binding.dart 587:19                                drawFrame
    packages/flutter/src/widgets/binding.dart 991:13                                  drawFrame
    packages/flutter/src/rendering/binding.dart 448:5                                 [_handlePersistentFrameCallback]
    packages/flutter/src/scheduler/binding.dart 1386:7                                [_invokeFrameCallback]
    packages/flutter/src/scheduler/binding.dart 1311:9                                handleDrawFrame
    packages/flutter/src/scheduler/binding.dart 1169:5                                [_handleDrawFrame]
    lib/_engine/engine/platform_dispatcher.dart 1346:5                                invoke
    lib/_engine/engine/platform_dispatcher.dart 260:5                                 invokeOnDrawFrame
    lib/_engine/engine/initialization.dart 185:36                                     <fn>
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 550:37  _checkAndCall
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 555:39  dcall
    

    Note my error is the same as 141253, which has been closed.

  4. luckyhandler commented on Feb 22, 2024

    @luckyhandler

    After upgrading my flutter web project to flutter 3.19.1 I get on Intellij

    Assertion failed: org-dartlang-sdk:///lib/_engine/engine/window.dart:91:12
    !isDisposed
    "Trying to render a disposed EngineFlutterView."
    

    like in #141253 when hot restarting the app. It still continues to work.

    But

    • on VS Code on saving the code and
    • on the terminal when pushing 'r'

    I get into a weird routing state using router.

    Not sure what is different in Intellij Build #IC-233.11799.241 and Terminal / or VsCode.
    Maybe helps as hint...

    UPDATE: I also upgraded router together with flutter from 10.0.0 to 13.2.0 --> Downgrading solves the issue for me again. So it's probably also for other folks related to router.

  5. 26 remaining items

  6. acpSiam commented on Apr 2, 2025

    @acpSiam

    Same issue happening here but, in my case, I am pretty sure it's causing by some of my codes. I just cannot find which part of the code is causing this. I wish there was more in-depth debug information available.

    ======== Exception caught by scheduler library =====================================================
    The following assertion was thrown during a scheduler callback:
    Assertion failed: org-dartlang-sdk:///lib/_engine/engine/window.dart:100:12
    !isDisposed
    "Trying to render a disposed EngineFlutterView."
    
    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               assertFailed
    dart-sdk/lib/_internal/js_dev_runtime/private/profile.dart 117:39               render
    packages/flutter/src/rendering/view.dart 363:7                                  compositeFrame
    packages/flutter/src/rendering/binding.dart 621:19                              drawFrame
    packages/flutter/src/widgets/binding.dart 1231:13                               drawFrame
    packages/flutter/src/rendering/binding.dart 482:5                               [_handlePersistentFrameCallback]
    packages/flutter/src/scheduler/binding.dart 1442:7                              [_invokeFrameCallback]
    packages/flutter/src/scheduler/binding.dart 1355:9                              handleDrawFrame
    packages/flutter/src/scheduler/binding.dart 1208:5                              [_handleDrawFrame]
    lib/_engine/engine/platform_dispatcher.dart 1347:5                              invoke
    lib/_engine/engine/platform_dispatcher.dart 301:5                               invokeOnDrawFrame
    lib/_engine/engine/initialization.dart 190:36                                   <fn>
    dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 224:27  _callDartFunctionFast1
    ====================================================================================================
    
  7. graemep-nz commented on Jun 19, 2025

    @graemep-nz
  8. anilari commented on Aug 25, 2025

    @anilari

    I have same problem with 3.35.1

    Assertion failed: org-dartlang-sdk:///lib/_engine/engine/window.dart:99:12
    !isDisposed
    "Trying to render a disposed EngineFlutterView."

    When I try to debug my application it always opens somewhere inside of the framework and distracting my development.

  9. nshahan commented on Sep 4, 2025

    @nshahan
    Contributor

    Notes for a future investigation from a random hallway conversation today:

    These errors could be caused by scheduling a callback for after a frame renders.

    domWindow.requestAnimationFrame((JSNumber highResTime) {
    // Reset immediately for two reasons:
    //
    // * While drawing a frame the framework may attempt to schedule a new
    // frame, e.g. when there's a continuous animation.
    // * If this value is stuck in `true` state, there will be no way to
    // schedule new frames and the app will freeze. It is therefore the
    // safest to reset this value before running any significant amount of
    // functionality that may throw exceptions, or produce wasm traps.
    _isFrameScheduled = false;
    try {
    _isRenderingFrame = true;
    _frameData = ui.FrameData(frameNumber: _frameData.frameNumber + 1);
    _renderFrame(highResTime.toDartDouble);
    } finally {
    _isRenderingFrame = false;
    onFinishedRenderingFrame?.call();
    }
    });

    It looks like this could be scheduling a callback on the JavaScript side which means it could persist after a hot restart.

    It sounds like there is an API to schedule a callback for after a frame render. We should experiment and see if we can repro the issues with it.

    If that does repro, we could potentially add checks to ensure the callback runs in the same generation of the application or cancel it if it was scheduled before a hot restart of the application and tries to run after.

  10. plchekspend commented on Sep 18, 2025

    @plchekspend

    Facing the same issue with Flutter 3.35.3

    Assertion failed: org-dartlang-sdk:///lib/_engine/engine/window.dart:99:12
    !isDisposed
    "Trying to render a disposed EngineFlutterView."
    Another exception was thrown: Assertion failed: org-dartlang-sdk:///lib/_engine/engine/window.dart:99:12

    Facing this on flutter web also i noticed that when i used dialogue on certain screen and when popping that dialogue facing this error logs exception.
    Now it logs continuously whichever part go to in app.

  11. eli1stark commented on Sep 18, 2025

    @eli1stark

    @nshahan

    Thank you for the follow-up! This is a framework issue that can be consistently reproduced using the sample code below.

    Reproduction steps:

    1. Run the code below in Chrome (or Chrome emulator)
    2. Repeatedly alternate between hot reload and hot restart
    3. The issue typically reproduces within 1 minute of testing
    Sample code
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const App());
    }
    
    class App extends StatelessWidget {
      const App({super.key});
    
      @override
      Widget build(BuildContext context) {
        return WidgetsApp(
          color: Colors.white,
          builder: (context, child) {
            return const Scaffold();
          },
        );
      }
    }
    Flutter doctor output
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.35.3, on macOS 15.6.1 24G90 darwin-arm64, locale en-US)
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [✓] Xcode - develop for iOS and macOS (Xcode 26.0)
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 2025.1)
    [✓] VS Code (version 1.96.4)
    [✓] Connected device (4 available)
    [✓] Network resources
    
    • No issues found!
    

    Please consider upgrading this from P3 to P2 given its impact on web development, community engagement (👍), and that it's been pending since 2023.

  12. added
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    on Sep 22, 2025
  13. github-actions commented on Oct 8, 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.

  14. locked as resolved and limited conversation to collaborators on Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectassigned for triageissue is assigned to a domain expert for further triagecustomer: crowdAffects or could affect many people, though not necessarily a specific customer.e: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webengineflutter/engine related. See also e: labels.found in release: 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: hot reloadReloading code during "flutter run"team-webOwned by Web platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-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