Dart-code: Blank screen when debugging Flutter apps in VS Code without logging enabled

Created on 30 Mar 2018  路  24Comments  路  Source: Dart-Code/Dart-Code

Hello!

I was chatting on Gitter regarding this issue already, and it appears to be related to Issue #747 in symptoms. Long story short, when I hit F5 to debug a Flutter application in VS Code, it attempts to start the app in the emulator (Android, to be specific) but gets stuck on a blank screen.

I received the advice to try enabling FlutterRun logging as well as Observatory logging, and upon doing so, the problem seems to resolve itself. When the logs are disabled, the problem persists, with the exception of two instances where it did work successfully. These exceptional scenarios are not easily repeatable though.

I can start the app without debugging using control + F5, and it works successfully. In addition, I can start debugging using the debugging pane and clicking the start button from there. Those appear to be unaffected at this time.

I provided logs earlier to the email address in the instructions for enabling logging. Here are a couple additional pieces of info, in case they help.

I am on the beta channel of Flutter, though all three branches seem to be affected.

I am on Windows 10 with the latest version of the Dart-Code extension.

If there is anything else I can do to assist, or if you have any questions, please let me know. I would be more than happy to assist with this.

Sincerely,
Derik

cannot reproduce

Most helpful comment

Ok, we don't need a new release because of how arguments to flutter run work :) Could you open your launch.json (if you don't have one, click the cog icon on the debug sidebar) and add the args shown below:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter",
            "request": "launch",
            "type": "dart",
            "args": [
                "--record-to",
                "bugreport",
                "--verbose",
                "--trace-startup"
            ]
        }
    ]
}

This will enable a bunch of diagnostics in the output and also to a folder called bugreport (if you need to test this multiple times, you'll need to change the folder name or rename it - it won't overwrite an existing folder).

Repro the issue with as many of those options set (bugreport is an arg to --report-to so those need to be added/removed as a pair) and then zip up the logs and a copy of the debug pane (you can right-click -> Copy All) and attach here or email to [email protected].

All 24 comments

Something I forgot to ask - did you have the Debug Console visible and if so, was there any useful info in there?

I did. Nothing there seemed too useful, I'm afraid. Though being a Flutter novice, I could be wrong.

image

Nope, you're right - nothing useful there.

So far I've been unable to repro this on either of my MacBooks :( If you turn off logging, how often does it occur? I've reviewed the logging code again but I still can't see any reason why this should affect it (we open a stream on first log, and then just write to it each time we talk to the processes - and AFAICT it's async, so it shouldn't even really affect timing much).

If I turn off logging, I have only had 2 instances in which pressing F5 allows me to debug successfully. So I would say the issue comes up ~95% of the time when logging is disabled, just as a rough estimate.

Do you know if you see this on a real device as well as the simulator? I realise you're on Windows so I'm trying to repro there now (I was previously trying on macs) but no luck on my device. My simulators are a bit messed up right now (they hang with blank screens and startup, coincidentally) but I'll see if I can get them going again.

Managed to get my emulator working on Windows, but still can't repro this :(

Could you try by enabling only the Flutter Run log (not observatory) to see whether it repros with only that one (I suspect not, since I don't think observatory is connecting), but it's worth a shot.

Otherwise, I might have a way of enabling logging inside Flutter (so we don't need to do it) that might allow us to get logs without you needing our logging enabled. If I prepare a custom build (the same as v2.11.2 but with some additional options) would you be able to install it (it's simple to do) and capture new logs?

Ok, we don't need a new release because of how arguments to flutter run work :) Could you open your launch.json (if you don't have one, click the cog icon on the debug sidebar) and add the args shown below:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter",
            "request": "launch",
            "type": "dart",
            "args": [
                "--record-to",
                "bugreport",
                "--verbose",
                "--trace-startup"
            ]
        }
    ]
}

This will enable a bunch of diagnostics in the output and also to a folder called bugreport (if you need to test this multiple times, you'll need to change the folder name or rename it - it won't overwrite an existing folder).

Repro the issue with as many of those options set (bugreport is an arg to --report-to so those need to be added/removed as a pair) and then zip up the logs and a copy of the debug pane (you can right-click -> Copy All) and attach here or email to [email protected].

I am trying this now with your logging disabled. My first attempt actually worked, so...yeah. Going to try again, just to be sure.

Alright, I was able to replicate the issue with the logging enabled via launch.json like you had recommended. Unfortunately, the size of the resulting directory was >50MB. As such, I zipped it up, put it in my personal OneDrive and emailed you a link to download it. Let me know if there is anything else I can to do help you out.

I had completely forgotten to include a copy of the contents of the debug console output. I sent that to you as a separate email.

I don't seem to have had the email with the debug console output, only one with a link to the zip file.

There are a bunch of errors listed in 024.adb.8704.stdout in the zip, but I think they're mostly unrelated. There are multiple outputs showing Observatory starting, I'm not sure if that's normal.

04-04 22:47:18.727 I/flutter ( 4403): Observatory listening on http://127.0.0.1:56293/
04-04 22:50:06.704 I/flutter ( 4601): Observatory listening on http://127.0.0.1:44184/
04-04 22:51:27.078 I/flutter ( 4714): Observatory listening on http://127.0.0.1:58710/

Just a thought! Can you try running flutter run --machine directly from the command line the same way Dart Code does? This will give you all the output we would write to the log on the screen. From your project folder, run this:

flutter run --machine -t lib/main.dart --start-paused

Note: In this case you will always get a white screen (because we're not attaching a debugger to unpause), but it's the output we're interested in. Specifically, does it contain an app.started event coming back with an observatoryUri.

Uh, so good and bad news. Visual Studio Code updated today, and since then I am no longer able to replicate the issue.

Hmm, I'm gonna close this for now (since I don't think we can debug any further) but if you ever see it again, do shout so we can investigate further.

Something else that occurred to me - when I ran this on my machine recently, I got a firewall prompt asking if I would allow one of the processes to listen for connections - if I hadn't accepted that, it's possible weird things like this might happen?

Hopefully commenting on here doesn't reopen this for you, rather I just wanted to keep you posted. So the first time I tried debugging a Flutter app, I was prompted to allow it access through the firewall, which I did accept.

I also tried running the command you requested, and surprisingly enough the app still fired up. Didn't even stay on the blank screen. Not sure why that is, but oh well. No sense diverting your efforts if we can't replicate this issue though. If it comes back up, I will reopen this issue.

Thanks for the info! I've been working on debug adapter tests recently to try and get better coverage here. I did find a bug that may introduce a race (https://github.com/Dart-Code/Dart-Code/issues/790) but I don't think it could cause this (I've found some other issues too, though not sure it'd cause this).

Do shout if you see it again - if there are bugs/races, it's unlikely they'll only affect one person, so I'd really love to get to the bottom of them.

sorry but @ndguardian what's the name of vscode theme ?

@lyquocnam The theme is called Ayu Dark. Sorry for the delay in answering...been busy offline for the past few weeks.

Hey @ndguardian , I have a frozen black screen of a Pixel Emulator. I cant even close it because the buttons on it are deactivated. I can work around it and plugged in devices are fine and I can run another emulator but this black screen is stuck on my windows laptop. You seem to have had this too so..

screenshot 1

And I cant close or remove it because it says the file is open. So I cant remove the pixel emulator although not sure if it will help. This is weird. It seems to not affect anything but its stuck there. This is from a flutter app I was debugging and running in VS code

@DanTup , any idea how I can get this screen off of my laptop. Its frozen. I cant move or delete it. It happened while I was debugging. I believe if I remember right I opened the emulator in vs code and right away hit debug. Like I cant close it or move it or anything. I can work around it still and open other emulators

Actually @DanTup I just opened code and opened a project and it still shows this emulator open. Do you have any suggestions

screenshot 2
@DanTup

@Isonomic I replied at https://github.com/flutter/flutter/issues/16865. If you can reliably reproduce this after a reboot please post a comment back there and we can see what we can do to troubleshoot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

e200 picture e200  路  3Comments

atreeon picture atreeon  路  5Comments

ifredom picture ifredom  路  3Comments

DanTup picture DanTup  路  4Comments

jascodes picture jascodes  路  4Comments