flame-engine / flame

A Flutter based game engine.
https://flame-engine.org
MIT License
9.19k stars 899 forks source link

Unverified Breakpoint in VSCode. DebugService: Error serving requestsError: FormatException: Unsupported URI form. #3126

Closed DanielJaramillo94 closed 5 months ago

DanielJaramillo94 commented 5 months ago

What happened?

I'm learning to use Flame and I have a little project setted up. Thing is I want to use the debbuger but I can't in my desktop PC but in the laptop I actually can. I thought was my desktop so I reinstalled VSCode and even formatted the PC but the error persists.

I have 2 breakpoints:

  1. main.dart, line 5
  2. pixel_adventure.dart, line 5

The execution code stops in breakpoint 1, as expected, but it doesn't stop in breakpoint 2. When I do click "Step into" when I'm on breakpoint 1, the debug console prints the next error: DebugService: Error serving requestsError: FormatException: Unsupported URI form: C:/Users/daniJ/AppData/Local/Pub/Cache/hosted/pub.dev/flame-1.17.0/lib/src/components/sprite_animation_group_component.dart

The breakpoint 2 is marked as "Unverified endpoint" everytime, as if the execution code wouldn't be able to reach it. I narrow this code to show the problem but in my project, apart from the breakpoint bug, everything works as expected.

Weird thing is that I do one of the following things, bugs dissapear:

I also raised this bug in the Flutter repo as I'm not sure if the problem is from Flutter or Flame https://github.com/flutter/flutter/issues/146795

What do you expect?

I expect the stop execution stops on breakpoints 1 and 2 when running the project in debug mode

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?

Example Lib folder in project structure (only 3 files): >lib (folder) main.dart pixel_adventure.dart components (folder) >>player.dart `main.dart` ```dart import 'package:flutter/material.dart'; import 'package:pixel_adventure/pixel_adventure.dart'; void main() async { final game = PixelAdventure(); runApp( Container(), ); } ``` `pixel_adventure.dart` ```dart import 'package:pixel_adventure/components/player.dart'; class PixelAdventure { PixelAdventure() { final player = Player(); } } ``` `player.dart` ```dart import 'package:flame/components.dart'; import 'package:flutter/services.dart'; import 'package:pixel_adventure/pixel_adventure.dart'; class Player extends SpriteAnimationGroupComponent with KeyboardHandler { @override bool onKeyEvent(RawKeyEvent event, Set keysPressed) { return super.onKeyEvent(event, keysPressed); } } ```

Relevant log output

Here is the error shown in the debug console when click "Step into" (debugging options) while the code is stopped in breakpoint 1

DebugService: Error serving requestsError: FormatException: Unsupported URI form: C:/Users/daniJ/AppData/Local/Pub/Cache/hosted/pub.dev/flame-1.17.0/lib/src/components/sprite_animation_group_component.dart

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

[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.22631.2861], locale es-CO) • Flutter version 3.19.5 on channel stable at C:\Users\daniJ\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 300451adae (3 weeks ago), 2024-03-27 21:54:07 -0500 • Engine revision e76c956498 • Dart version 3.3.3 • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\daniJ\AppData\Local\Android\sdk • Platform android-34, build-tools 34.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2023.2) • Android Studio at C:\Program Files\Android\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.9+0--11185874)

[√] VS Code (version 1.88.1) • VS Code at C:\Users\daniJ\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.86.0

[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.2861] • Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.123 • Edge (web) • edge • web-javascript • Microsoft Edge 123.0.2420.97

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

! Doctor found issues in 1 category.

Affected platforms

Web

Other information

No response

Are you interested in working on a PR for this?

ufrshubham commented 5 months ago

I could not reproduce the problem with the example you shared. For me, both the breakpoints work as expected. So probably this is not a bug in Flame's code. But I noticed one weird thing in your code. If you are using the latest version of Flame, the onKeyEvent should be using KeyEvent instead of RawKeyEvent. It must be showing up as an error.

DanielJaramillo94 commented 5 months ago

Thank you for the catch of the onKeyEvent function error. I repeatedly have to change between Flutter versions and I pasted the example code while working with SDK 3.16.9 and the flutter doctor -v while working with 3.19.5. That doesn't really matter as I having the error in both Flutter versions.

As you, I also think the error is not in Flame code... not even sure if it is on Flutter framework itself, because breakpoints are working as expected in my laptop... not sure how to solve the error tho, because I even formatted my desktop PC!

ufrshubham commented 5 months ago

If it is an issue with your local development environment, having this issue open on Flame isn't of much use.

spydon commented 5 months ago

I would recommend joining our discord (or the Flutter discord) and asking there.

vmtest888 commented 5 months ago

It also appeared in my environment, win10, flame is 1.17.0

image

[✓] Flutter (Channel stable, 3.19.6, on Microsoft Windows [版本 10.0.19044.4291], locale zh-CN) • Flutter version 3.19.6 on channel stable at D:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 54e66469a9 (3 weeks ago), 2024-04-17 13:08:03 -0700 • Engine revision c4cd48e186 • Dart version 3.3.4 • DevTools version 2.31.1 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn

DebugService: Error serving requestsError: FormatException: Unsupported URI form: C:/Users/Administrator/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/flame-1.17.0/lib/src/components/sprite_component.dart

spydon commented 5 months ago

Just linking this one: https://github.com/flutter/flutter/issues/146795