Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flame throws exception in Web / Chrome on Restart #3345

Open
1 task
crcdng opened this issue Oct 16, 2024 · 4 comments
Open
1 task

Flame throws exception in Web / Chrome on Restart #3345

crcdng opened this issue Oct 16, 2024 · 4 comments
Labels

Comments

@crcdng
Copy link

crcdng commented Oct 16, 2024

What happened?

Minimal Flame example throws Exception in Flutter Web with message "Trying to render a disposed EngineFlutterView." (to reproduce see below). Tested with Flame 1.20 and 1.19 / Flutter 3.24.3 / VSCode on Mac with Chrome

What do you expect?

No exception thrown

How can we reproduce this?

  1. Flutter -> New Project -> Empty Application

  2. Select Chrome / Web

  3. Run / Debug

  4. Open Javascript console

  5. Restart (try a few times)
    --> Exception is not thrown

  6. In Terminal flutter pub add flame

  7. replace contents of main.dart with

import 'package:flame/game.dart';
import 'package:flutter/widgets.dart';

void main() {
  final game = FlameGame();
  runApp(GameWidget(game: game));
}   

(same as https://docs.flame-engine.org/latest/tutorials/bare_flame_game.html)

  1. Restart (try a few times)
    --> Exception is thrown

What steps should take to fix this?

Hmmmmmmmmmmmmm

Do have an example of where the bug occurs?

see above
this error does not occur in the zap.run environment which does not implement restart

Relevant log output

══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
js_primitives.dart:28 The following assertion was thrown during a scheduler callback:
js_primitives.dart:28 Assertion failed: org-dartlang-sdk:///lib/_engine/engine/window.dart:102:12
js_primitives.dart:28 !isDisposed
js_primitives.dart:28 "Trying to render a disposed EngineFlutterView."
js_primitives.dart:28 
js_primitives.dart:28 When the exception was thrown, this was the stack:
js_primitives.dart:28 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3     throw_
js_primitives.dart:28 dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3      assertFailed
js_primitives.dart:28 lib/_engine/engine/window.dart 102:13                                           render
js_primitives.dart:28 packages/flutter/src/rendering/view.dart 353:7                                  compositeFrame
js_primitives.dart:28 packages/flutter/src/rendering/binding.dart 607:19                              drawFrame
js_primitives.dart:28 packages/flutter/src/widgets/binding.dart 1164:13                               drawFrame
js_primitives.dart:28 packages/flutter/src/rendering/binding.dart 468:5                               [_handlePersistentFrameCallback]
js_primitives.dart:28 packages/flutter/src/scheduler/binding.dart 1397:7                              [_invokeFrameCallback]
js_primitives.dart:28 packages/flutter/src/scheduler/binding.dart 1318:9                              handleDrawFrame
js_primitives.dart:28 packages/flutter/src/scheduler/binding.dart 1176:5                              [_handleDrawFrame]
js_primitives.dart:28 lib/_engine/engine/platform_dispatcher.dart 1408:5                              invoke
js_primitives.dart:28 lib/_engine/engine/platform_dispatcher.dart 310:5                               invokeOnDrawFrame
js_primitives.dart:28 lib/_engine/engine/initialization.dart 187:36                                   <fn>
js_primitives.dart:28 dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 188:27  _callDartFunctionFast1

Execute in a terminal and put output into the code block below

Output of: flutter doctor -v

[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-x64, locale
en-GB)
• Flutter version 3.24.3 on channel stable at
/Users/m/root/dev/flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2663184aa7 (5 weeks ago), 2024-09-11 16:27:48 -0500
• Engine revision 36335019a8
• Dart version 3.5.3
• DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at /Users/m/Library/Android/sdk
• Platform android-34, build-tools 35.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16A242d
• CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.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
17.0.11+0-17.0.11b1207.24-11852314)

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

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS
15.0.1 24A348 darwin-x64
• Chrome (web) • chrome • web-javascript • Google
Chrome 129.0.6668.101
! Device emulator-5562 is offline.

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

Affected platforms

Web

Other information

Haven't seen this before

Are you interested in working on a PR for this?

  • I want to work on this
@crcdng crcdng added the bug label Oct 16, 2024
@crcdng crcdng changed the title Flame throws exception in Web / Chrome after Hot Restart Flame throws exception in Web / Chrome on Hot Restart Oct 16, 2024
@crcdng crcdng changed the title Flame throws exception in Web / Chrome on Hot Restart Flame throws exception in Web / Chrome on Restart Oct 16, 2024
@spydon
Copy link
Member

spydon commented Oct 16, 2024

Interesting, this sounds like a Flutter issue.
Could you try running it with an older flutter version?

@crcdng
Copy link
Author

crcdng commented Oct 16, 2024

Interesting, this sounds like a Flutter issue. Could you try running it with an older flutter version?

Note the pure Flutter app does not throw, only with Flame (see reproduce steps)

I would need to install something to manage multiple flutter versions, what do you recommend? Or use flutter downgrade?

@spydon
Copy link
Member

spydon commented Oct 16, 2024

Note the pure Flutter app does not throw, only with Flame (see reproduce steps)

Yeah I noticed that, it can still be a Flutter issue though.

I would need to install something to manage multiple flutter versions, what do you recommend? Or use flutter downgrade?

If Flutter downgrade takes you far enough back that works, otherwise I'd recommend https://fvm.app

@crcdng
Copy link
Author

crcdng commented Oct 16, 2024

OK, this is pretty weird. I am seeing the same error on my Windows machine with Flutter 3.19.6. But this time it also throws in the Flutter app, not just with Flame.

Update: I then upgraded Flutter on the Windows Machine to the current version 3.24.3 and created a new Project, first pure Flutter then the Flame example (as described in how to reproduce above). Only the Flame app throws, same behaviour as described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@spydon @crcdng and others