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

Partially consuming the output of componentsAtPoint breaks rendering #2844

Open
misha opened this issue Nov 7, 2023 · 1 comment
Open

Partially consuming the output of componentsAtPoint breaks rendering #2844

misha opened this issue Nov 7, 2023 · 1 comment
Labels

Comments

@misha
Copy link

misha commented Nov 7, 2023

Current bug behavior

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.

Expected behavior

The circle should not go away.

Steps to reproduce

Basically what is in the description. I have a repository containing the code here:

https://github.com/misha/flame_debug

Flutter doctor output

$ 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!

More environment information

  • Flame version: 1.10.1
  • Platform affected: tested on Linux (Ubuntu 22.04)

Log information

N/A

More information

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.

@misha misha added the bug label Nov 7, 2023
@misha misha changed the title Using an iterator with TapDetector appears to break rendering Partially consuming the output of componentsAtPoint breaks rendering Nov 7, 2023
@ufrshubham
Copy link
Collaborator

Hey @misha can you share a minimal reproducible example for this? Also would you be interested in working on this?

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

2 participants