Skip to content

Support debug mode for WASM builds #148850

Closed

Description

@Rexios80

Steps to reproduce

  1. Create a new project
  2. Call print(kDebugMode)
  3. Run flutter run --debug -d chrome --wasm
  4. It prints false

Expected results

It prints true

Actual results

It prints false

Code sample

Code sample
import 'package:flutter/foundation.dart';

void main() {
  print(kDebugMode);
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
rexios@Aarons-MBP pub_stats % flutter doctor -v
[✓] Flutter (Channel main, 3.22.0-42.0.pre.6, on macOS 14.5 23F79 darwin-arm64, locale en-US)
    • Flutter version 3.22.0-42.0.pre.6 on channel main at /Users/rexios/repos/flutter
    • Upstream repository [email protected]:flutter/flutter.git
    • Framework revision 112e8b5509 (4 hours ago), 2024-05-22 09:25:21 +0200
    • Engine revision c89defa558
    • Dart version 3.5.0 (build 3.5.0-177.0.dev)
    • DevTools version 2.36.0-dev.10

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/rexios/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio Preview.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version unknown)
    • Android Studio at /Applications/Android Studio Preview.app/Contents
    • 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
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (4 available)
    • Aaron’s iPhone (mobile)         • 00008130-001C35CE3A20001C • ios            • iOS 17.5.1 21F90
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 124.0.6367.208

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

! Doctor found issues in 1 category.

Activity

  1. darshankawar commented on May 22, 2024

    @darshankawar
    Member

    3. Run flutter run --debug -d chrome --wasm

    @Rexios80 According to https://docs.flutter.dev/platform-integration/web/wasm#only-build-support, currently wasm has only build support and not flutter run, so could be that you are seeing the reported behavior.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 22, 2024
  3. Rexios80 commented on May 22, 2024

    @Rexios80
    MemberAuthor

    I am running the latest Flutter main commit which does support flutter run. Should I not report issues with using it?

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 22, 2024
  5. darshankawar commented on May 23, 2024

    @darshankawar
    Member

    Thanks for the feedback. It seems the said command doesn't work in stable yet, so I thought to refer the documentation if that's the case, but I checked in master which ran the command and printed false as below:

    Screenshot 2024-05-23 at 11 29 25 AM

    Keeping the issue open and labeling for team's tracking.

  6. added
    platform-webWeb applications specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    e: wasmIssues related to the wasm build of Flutter Web.
    team-webOwned by Web platform team
    on May 23, 2024
  7. 8 remaining items

  8. eyebrowsoffire commented on Jun 4, 2024

    @eyebrowsoffire
    Contributor

    That cannot be intentional. Either it should warn/error on the --wasm flag or it should run in release mode with wasm and not claim it supports hot-reload

    It is hot restart, not hot reload, and it does actually work. If you make a change to the code and then press "r", it will recompile the code and send a signal to chrome to reload, and it will do so. This is the existing behavior for flutter build web --release, which uses dart2js.

    Are we saying that there is no way to compile to WASM in such a way that kDebugMode would be true and that is intentional?

    Yes. Wasm compilation does not support debug mode currently.

  9. Rexios80 commented on Jun 10, 2024

    @Rexios80
    MemberAuthor

    Is there an existing issue to support debug mode in WASM builds or should we repurpose this one to be it?

  10. Rexios80 commented on Jul 11, 2024

    @Rexios80
    MemberAuthor

    @eyebrowsoffire sorry for the ping but I would like to clarify this if possible. Should we create an issue to support debug mode in WASM builds or is there already an existing issue for that?

  11. eyebrowsoffire commented on Jul 11, 2024

    @eyebrowsoffire
    Contributor

    Let's repurpose this bug to track that.

  12. changed the title [-]`kDebugMode` is false when running `flutter run --debug -d chrome --wasm`[/-] [+]Support debug mode for WASM builds[/+] on Jul 11, 2024
  13. Rexios80 commented on Jul 23, 2024

    @Rexios80
    MemberAuthor

    @eyebrowsoffire What is the reason we can't just make kDebugMode true with flutter run --wasm and false with flutter run --wasm --release? Are there bigger implications that I'm not seeing? The biggest use-case for this in my projects is using Firebase emulators when kDebugMode is true, which makes testing locally with WASM really annoying.

  14. eyebrowsoffire commented on Jul 23, 2024

    @eyebrowsoffire
    Contributor

    We can do as you're suggesting, I just haven't implemented it yet. The reason it is the way it is right now is just mostly implementation warts. I plan on at least making it so that kDebugMode is true here, even if you won't get a full "debug mode" experience (attaching devtools, etc).

  15. eyebrowsoffire commented on Jul 25, 2024

    @eyebrowsoffire
    Contributor

    Fixed with #152262

  16. Rexios80 commented on Jul 26, 2024

    @Rexios80
    MemberAuthor

    Confirmed kDebugMode is true when running flutter run -d chrome --wasm on Flutter master

  17. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jul 26, 2024
  18. github-actions commented on Aug 9, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work liste: wasmIssues related to the wasm build of Flutter Web.found in release: 3.22Found to occur in 3.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions