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

Component.removeWhere throwing Concurrent modification during iteration Exception #2424

Closed
trunghq3101 opened this issue Mar 23, 2023 · 4 comments · Fixed by #2458
Closed
Labels
blocking release This needs to be fixed to be able to release the next version bug

Comments

@trunghq3101
Copy link
Contributor

Current bug behavior

In the onLoad of a component that has just been pushed to the router, I call the removeWhere() function on an unmounted component. It throws this exception:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Concurrent modification during iteration: _Set len:1.

Expected behavior

It worked fine on flame: 1.6.0

Steps to reproduce

Flutter doctor output

Output of: flutter doctor -v

More environment information

  • Flame version: main
  • Platform affected: desktop

Log information

#2      Component.removeWhere
component.dart:617
#3      Level1OpeningScene.call.hidePlaygroundAndRunButon
level_1_opening_scene.dart:44
#4      Level1OpeningScene.call
level_1_opening_scene.dart:48
#5      Level1.onLoad
level_1.dart:67
#6      Component._startLoading
component.dart:824
#7      Component._addChild
component.dart:591
#8      Component.addToParent
component.dart:562
#9      Route.didPush
route.dart:137
#10     RouterComponent.pushNamed
router_component.dart:106
#11     new HomePage.<anonymous closure>
home_page.dart:10
#12     ButtonComponent.onTapDown
button_component.dart:6

More information

@spydon
Copy link
Member

spydon commented Mar 23, 2023

@st-pasha this is a regression right, and not intentional?

@spydon spydon added the blocking release This needs to be fixed to be able to release the next version label Mar 31, 2023
@spydon
Copy link
Member

spydon commented Mar 31, 2023

@trunghq3101 I'm failing to reproduce, this but I'm probably doing something wrong. Could you post a MRE for this one?

@spydon
Copy link
Member

spydon commented Apr 2, 2023

Okay, managed to do a MRE. It's not related to the router.
https://zapp.run/edit/flame-z91s06gva1t0?entry=lib/main.dart&file=lib/main.dart

import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(
    GameWidget(
      game: FlameGame(children: [RemoveWhereComponent()]),
    ),
  );
}

class RemoveWhereComponent extends Component {
  @override
  Future<void> onLoad() async {
    add(Component());
    removeWhere((_) => true);
  }
}

@spydon
Copy link
Member

spydon commented Apr 2, 2023

After yet another git bisect, #2300 shows to be the culprit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking release This needs to be fixed to be able to release the next version bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants