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

SpriteBatch not work in Chrome #561

Closed
1 of 3 tasks
unger1984 opened this issue Dec 7, 2020 · 3 comments · Fixed by #612
Closed
1 of 3 tasks

SpriteBatch not work in Chrome #561

unger1984 opened this issue Dec 7, 2020 · 3 comments · Fixed by #612

Comments

@unger1984
Copy link
Contributor

Description

doc/examples/sprite_batch not work in flutter web (Chrome). Crashed on render method of SpriteBatch

Development environment

Flame version:

branch develop

======== Exception caught by rendering library =====================================================
The following UnimplementedError was thrown during paint():
UnimplementedError

When the exception was thrown, this was the stack: 
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 216:49  throw_
lib/_engine/engine/html/canvas.dart 521:5                                     drawAtlas
packages/flame/sprite_batch.dart 73:11                                        render
packages/flame/components/sprite_batch_component.dart 21:17                   render
packages/flame/game/base_game.dart 113:6                                      renderComponent
...
The following RenderObject was being processed when the exception was fired: GameRenderBox#4579d
...  parentData: <none> (can use size)
...  constraints: BoxConstraints(w=500.0, h=966.0)
...  size: Size(500.0, 966.0)
RenderObject: GameRenderBox#4579d
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=500.0, h=966.0)
  size: Size(500.0, 966.0)
==========================================================================================

Flutter doctor:

[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Mac OS X 10.15.7 19H15 darwin-x64, locale ru)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.1.1)
[✓] Chrome - develop for the web
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
[✓] VS Code (version 1.51.1)
[✓] Connected device (3 available)

Runtime

This issue is related to running on which platform? (Select all that apply)

  • Android :android:
  • iOS 🍎
  • Web :browser:

Minimal reproducible code (Required for bugs)

https://github.com/flame-engine/flame/tree/develop/doc/examples/sprite_batch

@erickzanardo
Copy link
Member

SpriteBatch uses an API that is not available on web, I wonder if we should add an assert on it to check if this is running on web. Or if we could somehow implement the Spritebatch API without using drawAtlas. Any thoughts @wolfenrain ?

@unger1984
Copy link
Contributor Author

flutter/flutter#32217 canvas.drawAtlas added to the ToDo list with priority 5

@wolfenrain
Copy link
Contributor

SpriteBatch uses an API that is not available on web, I wonder if we should add an assert on it to check if this is running on web. Or if we could somehow implement the Spritebatch API without using drawAtlas. Any thoughts @wolfenrain ?

This is still my plan indeed, haven't gotten around on implementing it. It has some problematic caveats with it because of the RSTransforms that are used internally by the SpriteBatch. We cant reuse the transforms for other draw calls. So we need to introduce a different way of caching the original values.

The RSTransform only keeps the values that it calculates based on the arguments that go into its constructor. But we need the original arguments. One idea is wrapping the RSTransform into our own class that saves both the transform and the original values, so we can use either one of them depending on the platform.

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

Successfully merging a pull request may close this issue.

3 participants