Skip to content

QEMU launch may fail silently #4839

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

Closed
lukehutch opened this issue Nov 14, 2023 · 10 comments
Closed

QEMU launch may fail silently #4839

lukehutch opened this issue Nov 14, 2023 · 10 comments
Labels
in commands Relates to commands (usually invoked from the command Palette) in flutter Relates to running Flutter apps is bug
Milestone

Comments

@lukehutch
Copy link

Describe the bug

In Dart-Code, if I try to launch the Android emulator, and virtualization support is disabled in the BIOS, or another emulator such as VirtualBox is already running, then QEMU will fail to launch, but no error is shown to the user. VS Code just keeps showing a spinner saying it is waiting for the emulator to start.

Expected behavior

It would be nice if the user were alerted to the fact that QEMU couldn't be started.

@DanTup
Copy link
Member

DanTup commented Nov 15, 2023

Is it possible you can enable the Flutter Daemon log (https://dartcode.org/docs/logging/#flutter-daemon) and see what it captures when you hit this? Thanks!

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Nov 15, 2023
@lukehutch
Copy link
Author

lukehutch commented Nov 16, 2023

I see the following, if I'm running VirtualBox:

[2:39:11 AM] [FlutterDaemon] [Info] ==> [{"id":"54","method":"emulator.getEmulators"}]
[2:39:11 AM] [FlutterDaemon] [Info] <== [{"id":"54","result":[{"id":"Resizable_Experimental_API_33","name":"Resizable (Experimental) API 33","category":"mobile","platformType":"android"}]}]
[2:39:14 AM] [FlutterDaemon] [Info] ==> [{"id":"55","method":"emulator.launch","params":{"emulatorId":"Resizable_Experimental_API_33","coldBoot":false}}]
[2:39:17 AM] [FlutterDaemon] [Info] <== [{"event":"daemon.logMessage","params":{"level":"error","message":"The Android emulator exited with code 1 during startup"}}]
[2:39:17 AM] [FlutterDaemon] [Info] <== [{"event":"daemon.logMessage","params":{"level":"error","message":"Android emulator stderr:"}}]
[2:39:17 AM] [FlutterDaemon] [Info] <== [{"event":"daemon.logMessage","params":{"level":"error","message":"ERROR   | Running multiple emulators with the same AVD "}}]
[2:39:17 AM] [FlutterDaemon] [Info] <== [{"event":"daemon.logMessage","params":{"level":"error","message":"ERROR   | is an experimental feature."}}]
[2:39:17 AM] [FlutterDaemon] [Info] <== [{"event":"daemon.logMessage","params":{"level":"error","message":"ERROR   | Please use -read-only flag to enable this feature."}}]
[2:39:17 AM] [FlutterDaemon] [Info] <== [{"event":"daemon.logMessage","params":{"level":"error","message":"Address these issues and try again."}}]
[2:39:17 AM] [FlutterDaemon] [Info] <== [{"id":"55"}]

I assume the error message would be slightly different if virtualization is disabled, but the error "The Android emulator exited with code 1 during startup" is likely still the same (it is going to be a hassle to reboot right now to change the BIOS settings...)

@DanTup DanTup added this to the v3.78.0 milestone Nov 16, 2023
@DanTup DanTup added in flutter Relates to running Flutter apps in commands Relates to commands (usually invoked from the command Palette) and removed awaiting info Requires more information from the customer to progress labels Nov 16, 2023
@DanTup
Copy link
Member

DanTup commented Nov 16, 2023

Ah, I see. It seems like the errors aren't in the response to the launch request but just events. I think the best thing is probably for us to capture any logMessage events from the daemon into an Output pane, and automatically show it whenever an error shows up there.

@DanTup DanTup closed this as completed in eaf961b Nov 16, 2023
@lukehutch
Copy link
Author

@DanTup thanks for the quick fix!

@DanTup
Copy link
Member

DanTup commented Nov 16, 2023

np! If you didn't already see it, I pushed a pre-release version earlier that would've included this, so you should be able to test if you're on that (and let me know if you see anything not working right).

@lukehutch
Copy link
Author

@DanTup Yes, this worked! Thanks:

[ERR] The Android emulator exited with code 1 during startup
[ERR] Android emulator stderr:
[ERR] ERROR   | Running multiple emulators with the same AVD 
[ERR] ERROR   | is an experimental feature.
[ERR] ERROR   | Please use -read-only flag to enable this feature.
[ERR] Address these issues and try again.

It's probably a good idea to add "[ERR]" and "The Android emulator exited with code" to the list of things you catch.

I would prefer this output to be in the debug console, not the output pane, if that's possible, but that's no big deal.

@DanTup
Copy link
Member

DanTup commented Nov 16, 2023

The "[ERR]" text is added in the extension here so it won't be in the strings we check. I didn't include "The Android emulator exited with code" because I was nervous that it's generic enough that it might just show up when you close the emulator and there was existing code to show the output pane that had been disabled for being too aggressive, so I wanted to be careful.

If any cases come up where the existing text isn't matching though, I'm happy to revisit (or to try and push this up into flutter_tools to avoid what is essentially a bit of a hack here).

@lukehutch
Copy link
Author

Sounds good. Thanks!

@lukehutch
Copy link
Author

For the record, here is the error when virtualization is disabled. Your patch did catch this... but maybe add "emulation currently requires hardware acceleration"? Or not, it's not currently needed :-)

Starting device daemon...
[ERR] The Android emulator exited with code 1 during startup
[ERR] Android emulator stderr:
[ERR] ERROR   | x86_64 emulation currently requires hardware acceleration!
[ERR] CPU acceleration status: /dev/kvm is not found: VT disabled in BIOS or KVM kernel module not loaded
[ERR] More info on configuring VM acceleration on Linux:
[ERR] https://developer.android.com/studio/run/emulator-acceleration#vm-linux
[ERR] General information on acceleration: https://developer.android.com/studio/run/emulator-acceleration.
[ERR] Address these issues and try again.

@DanTup
Copy link
Member

DanTup commented Nov 20, 2023

I suspect it's not needed (I suspect "Address these issues and try again" will catch all of the issues we care about), but I did add "requires hardware acceleration" to the list just to be safe since it's pretty specific and unlikely to have false positives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in commands Relates to commands (usually invoked from the command Palette) in flutter Relates to running Flutter apps is bug
Projects
None yet
Development

No branches or pull requests

2 participants