I have a game with a red CircleComponent
using TapDetector
. In the onTapUp
callback, I have the following code:
void onTapUp(TapUpInfo info) {
componentsAtPoint(info.eventPosition.global)
.whereType<CircleComponent>()
.iterator
.moveNext();
}
I expected this code to be free of side effects and do basically nothing.
However, if you tap the circle 4 times, the circle goes away.
The critical part appears to be the call to moveNext
. The bug does not occur without it.
The circle should not go away.
Basically what is in the description. I have a repository containing the code here:
https://github.com/misha/flame_debug
$ flutter doctor -v
[β] Flutter (Channel beta, 3.16.0-0.4.pre, on Ubuntu 22.04.3 LTS
6.2.0-36-generic, locale en_US.UTF-8)
β’ Flutter version 3.16.0-0.4.pre on channel beta at
/home/misha/snap/flutter/common/flutter
β’ Upstream repository https://github.com/flutter/flutter.git
β’ Framework revision 379c3f4d37 (5 days ago), 2023-11-01 11:34:49 -0700
β’ Engine revision abdaabc6dc
β’ Dart version 3.2.0 (build 3.2.0-210.4.beta)
β’ DevTools version 2.28.1
[β] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
β’ Android SDK at /home/misha/Android/Sdk
β’ Platform android-33, build-tools 33.0.2
β’ ANDROID_HOME = /home/misha/Android/Sdk
β’ Java binary at: /opt/android-studio/jre/bin/java
β’ Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
β’ All Android licenses accepted.
[β] Chrome - develop for the web
β’ Chrome at google-chrome
[β] Linux toolchain - develop for Linux desktop
β’ clang version 10.0.0-4ubuntu1
β’ cmake version 3.16.3
β’ ninja version 1.10.0
β’ pkg-config version 0.29.1
[β] Android Studio (version 2020.3)
β’ Android Studio at /opt/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 11.0.10+0-b96-7249189)
[β] VS Code (version 1.84.1)
β’ VS Code at /usr/share/code
β’ Flutter extension version 3.76.0
[β] Connected device (2 available)
β’ Linux (desktop) β’ linux β’ linux-x64 β’ Ubuntu 22.04.3 LTS
6.2.0-36-generic
β’ Chrome (web) β’ chrome β’ web-javascript β’ Google Chrome 118.0.5993.117
[β] Network resources
β’ All expected network resources are available.
β’ No issues found!
N/A
This was happening on 1.9.1 as well, I upgraded to 1.10.1 in order to see if it was resolved.
Edit: On further research, it looks like leaving the iterator open is the culprit. If you do not go through all the elements produced by componentsAtPoint
, the bug occurs. I'm not aware if fully consuming all iterators in Dart is good practice or anything, I would expect the processing to just sort of stop at that position.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too