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

Crash when many collision happen #3347

Open
1 task
RafaelBarbosatec opened this issue Oct 17, 2024 · 8 comments · Fixed by bluefireteam/ordered_set#48
Open
1 task

Crash when many collision happen #3347

RafaelBarbosatec opened this issue Oct 17, 2024 · 8 comments · Fixed by bluefireteam/ordered_set#48
Labels

Comments

@RafaelBarbosatec
Copy link

RafaelBarbosatec commented Oct 17, 2024

What happened?

Crash when many collision happen

What do you expect?

Works fine like version 1.18.0

How can we reproduce this?

No response

What steps should take to fix this?

No response

Do have an example of where the bug occurs?

No response

Relevant log output

════════ Exception caught by scheduler library ═════════════════════════════════
The following _TypeError was thrown during a scheduler callback:
type 'Null' is not a subtype of type 'Component' in type cast

When the exception was thrown, this was the stack:
#0      _CompactIterator.current (dart:collection-patch/compact_hash.dart:728:29)
#1      _OrderedSetIterator.current (package:ordered_set/ordered_set.dart:191:36)
#2      Iterable.forEach (dart:core/iterable.dart:347:35)
#3      Component.updateTree (package:flame/src/components/core/component.dart:527:16)
#4      FlameGame.updateTree (package:flame/src/game/flame_game.dart:163:17)
#5      HasTimeScale.updateTree (package:flame/src/components/mixins/has_time_scale.dart:35:11)
#6      FlameGame.update (package:flame/src/game/flame_game.dart:152:7)
#7      HasQuadTreeCollisionDetection.update (package:flame/src/collisions/broadphase/quadtree/has_quadtree_collision_detection.dart:84:11)
#8      HasTimeScale.update (package:flame/src/components/mixins/has_time_scale.dart:30:11)
#9      BonfireGame.update (package:bonfire/base/bonfire_game.dart:188:11)
#10     GameRenderBox.gameLoopCallback (package:flame/src/game/game_render_box.dart:121:10)
#11     GameLoop._tick (package:flame/src/game/game_loop.dart:46:13)
#12     Ticker._tick (package:flutter/src/scheduler/ticker.dart:261:12)
#13     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397:15)
#14     SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1240:11)
#15     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#16     SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:1238:17)
#17     SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:1155:5)
#18     _invoke1 (dart:ui/hooks.dart:328:13)
#19     PlatformDispatcher._beginFrame (dart:ui/platform_dispatcher.dart:397:5)
#20     _beginFrame (dart:ui/hooks.dart:272:31)

This exception was thrown in the context of a scheduler callback. When the scheduler callback was _registered_ (as opposed to when the exception was thrown), this was the stack:
#2      SchedulerBinding.scheduleFrameCallback (package:flutter/src/scheduler/binding.dart:611:49)
#3      Ticker.scheduleTick (package:flutter/src/scheduler/ticker.dart:277:46)
#4      Ticker.start (package:flutter/src/scheduler/ticker.dart:183:7)
#5      GameLoop.start (package:flame/src/game/game_loop.dart:54:15)
#6      GameRenderBox._attachGame (package:flame/src/game/game_render_box.dart:97:16)
#7      GameRenderBox.attach (package:flame/src/game/game_render_box.dart:88:5)
#8      RenderObject.adoptChild (package:flutter/src/rendering/object.dart:1841:13)
#9      ContainerRenderObjectMixin.insert (package:flutter/src/rendering/object.dart:4324:5)
#10     MultiChildRenderObjectElement.insertRenderObjectChild (package:flutter/src/widgets/framework.dart:6974:18)
#11     RenderObjectElement.attachRenderObject (package:flutter/src/widgets/framework.dart:6732:35)
#12     RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6597:5)
#13     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468:16)
#14     MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:7035:36)
#15     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:7047:32)
#16     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468:16)
#17     Element.updateChild (package:flutter/src/widgets/framework.dart:3957:20)
#18     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
#19     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780:11)
#20     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
#21     BuildScope._tryRebuild (package:flutter/src/widgets/framework.dart:2693:15)
#22     BuildScope._flushDirtyElements (package:flutter/src/widgets/framework.dart:2752:11)
#23     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3048:18)
#24     _LayoutBuilderElement._rebuildWithConstraints (package:flutter/src/widgets/layout_builder.dart:231:12)
#25     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2719:59)
#26     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1098:15)
#27     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2719:14)
#28     RenderConstrainedLayoutBuilder.rebuildIfNecessary (package:flutter/src/widgets/layout_builder.dart:278:5)
#29     _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:369:5)
#30     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#31     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21)
#32     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#33     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21)
#34     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#35     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21)
#36     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#37     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21)
#38     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#39     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21)
#40     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#41     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21)
#42     _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1448:11)
#43     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#44     _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:371:14)
#45     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#46     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21)
#47     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#48     ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11)
#49     RenderStack._computeSize (package:flutter/src/rendering/stack.dart:595:43)
#50     RenderStack.performLayout (package:flutter/src/rendering/stack.dart:622:12)
#51     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#52     ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11)
#53     RenderStack._computeSize (package:flutter/src/rendering/stack.dart:595:43)
#54     RenderStack.performLayout (package:flutter/src/rendering/stack.dart:622:12)
#55     RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7)
#56     MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:173:12)
#57     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:1092:7)
#58     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:237:7)
#59     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:404:14)
#60     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2446:7)
#61     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1052:18)
#62     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1065:15)
#63     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:602:23)
#64     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1164:13)
#65     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:468:5)
#66     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397:15)
#67     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1318:9)
#68     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1176:5)
#69     _invoke (dart:ui/hooks.dart:312:13)
#70     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419:5)
#71     _drawFrame (dart:ui/hooks.dart:283:31)
(elided 2 frames from class _FrameCallbackEntry)
════════════════════════════════════════════════════════════════════════════════

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

[✓] Flutter (Channel stable, 3.24.0, on Zorin OS 17.1 6.5.0-25-generic, locale pt_BR.UTF-8)
    • Flutter version 3.24.0 on channel stable at /home/rafael/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 80c2e84975 (3 months ago), 2024-07-30 23:06:49 +0700
    • Engine revision b8800d88be
    • Dart version 3.5.0
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/rafael/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /home/rafael/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /var/lib/flatpak/exports/bin/com.google.Chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2023.1)
    • Android Studio at /home/rafael/android-studio
    • 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.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.93.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.98.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Zorin OS 17.1 6.5.0-25-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 130.0.6723.58

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

• No issues found!

Affected platforms

All

Other information

No response

Are you interested in working on a PR for this?

  • I want to work on this
@spydon
Copy link
Member

spydon commented Oct 17, 2024

This sounds like the same as #3319, but with a better description!

So it only happens when there are a lot of collisions? That's odd...
I can't reproduce it on the performance test https://examples.flame-engine.org/#/Sample_Games_Rogue_Shooter

Do you have any example project where it is easily reproduced?

@spydon
Copy link
Member

spydon commented Oct 17, 2024

It's definitely related to the latest ordered_set update, you should be able to do a dependency_override and point ordered_set at 6.0.1 as a workaround, and still use the newest Flame version.

@luanpotter seems like we introduced a bug in this PR: bluefireteam/ordered_set#46

@RafaelBarbosatec
Copy link
Author

Thanks for this information @spydon !
Will create a simple example with flame to try reproduce this and will post here.

@spydon
Copy link
Member

spydon commented Oct 20, 2024

Can you try if it works like it should with the newest release of ordered_set?

dependency_overrides:
  ordered_set: ^6.1.1

@RafaelBarbosatec
Copy link
Author

Hi @spydon !
There is something strange yet. Something crash but show nothing in the debug console.
I was trying reproduce it in the pure Flame project but nothing yet.
I'm investigating.

@spydon
Copy link
Member

spydon commented Oct 22, 2024

@RafaelBarbosatec that's odd, thanks for investigating!

@spydon
Copy link
Member

spydon commented Oct 28, 2024

I tried running with the performance test game (https://examples.flame-engine.org/#/Sample_Games_Rogue_Shooter) where there are lots of collisions, but I can't see any problems there.

@RafaelBarbosatec
Copy link
Author

Yes, there is any situation that cause this problem. I just not find out yet. The problem exist, because the other versions works fine.

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

Successfully merging a pull request may close this issue.

3 participants
@spydon @RafaelBarbosatec and others