flutter web crash on opening browser for debugging

Viewed 2661

I'm using Android Studio, when I run the project on chrome or edge I see the splash screen, and then, usually I see this:

EDIT - happened after adding await Firebase.initializeApp();

enter image description here

7 Answers

Muting all breakpoints and then running Debug worked for me.

Mute Breakpoints

I had this issue but “flutter clean” solved it.

I've had this problem as well, although it is not a solution (seems a problem with the web dev tools to me) a workaround appears to be to remove or mute your breakpoints before running debug!

I've been struggling with this problem for months. I isolated the cause, like you, to an external package but in my case, it was AWS Amplify but I believe they cause some Javascript issue/conflict with the debug tools.

So, as long as at the point you run the project in debug there aren't any active breakpoints it appears to run ok. You can then add your breakpoints afterwards. As mentioned if you don't want to reset your breakpoints each time, muting them before running the project in debug also works if your IDE allows.

It would be interesting to hear if this works for others as it seems to work for our team on both Windows and Mac debugging in Chrome with Android Studio.

Try to launch your application as a web server by adding -d web-server arguments, you need to add Dart Debug Chrome extension to your chrome navigator, if you want to test your app on release mode add --release to your commande.

If you use VS Code as your IDE, here is a launcher that can be used for mobile and web platform:

{
"version": "0.2.0",
"configurations": [
    {
        "name": "production",
        "request": "launch",
        "type": "dart",
    },
    {
        "name": "Web-release",
        "request": "launch",
        "type": "dart",
        "args":["--web-renderer","html","-d","web-server","--release"],
    },
    {
        "name": "Web-debug",
        "request": "launch",
        "type": "dart",
        "args":["--web-renderer","html","-d","web-server"],
    },
]}

You can escape "--web-renderer","html" if your application doesn't contain emojis or a package that handle images.

on android studio how your launcher should look like: enter image description here

As I mentioned in a comment, removing all breakpoints solves a different error message, but you can try and see if it also helps for this one.

The answer by TimMutlow resolved the issue for me(finally!), but I just cleared all breakpoints under Run > Remove All Breakpoints. However, the breakpoints I had set were still hit, even though they no longer showed in the IDE. I suspect some underlying issue where I had added a lot of breakpoints/modified code that needed to all be cleared from cache.

I also agree that this is a workaround to an IDE/Web Dev tools problem.

I had the same issue and had to run flutter run command to get it working

flutter run lib/main.dart
Related