Skip to content
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

Flutter seemingly not pushing new dev builds without first running flutter clean #147752

Closed
craiglabenz opened this issue May 2, 2024 · 12 comments
Labels
team-tool Owned by Flutter Tool team

Comments

@craiglabenz
Copy link
Contributor

Steps to reproduce

I have repeatedly seen $ flutter run not ship new builds to a test device (which has included physical Android and iOS devices, and also macOS desktop) without first running $ flutter clean.

I first encountered this bug earlier this week when @schmidt-sebastian was unable to successfully rebuild an example on his test Android device in a project we are working on together.

Then, I saw the error myself yesterday pushing the same project to my iOS device.

And then this morning while livestreaming, I encountered it again on an unrelated project. The part where I start encountering new code not getting executed begins here, after some unrelated distractions resumes with a compilation error during an attempted hot reload here, and then concludes with me eventually using $ flutter clean here.

Expected results

$ flutter run should either ship the new app or fail loudly.

Actual results

$ flutter run either silently fails to compile and ships the old build, or just ships the old build regardless.

Code sample

I will revisit a minimal reproduction soon, but wanted to at least start documenting this since I no longer believe it is simple user error.

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
$ flutter doctor -v
[✓] Flutter (Channel master, 3.22.0-18.0.pre.77, on macOS 14.4.1 23E224 darwin-arm64, locale en)
    • Flutter version 3.22.0-18.0.pre.77 on channel master at /Users/craiglabenz/Dev/git/flutter/flutter
    • Upstream repository git@github.com:flutter/flutter.git
    • Framework revision 3e399c1578 (2 days ago), 2024-04-30 13:25:24 -0700
    • Engine revision 0ce67714ce
    • Dart version 3.5.0 (build 3.5.0-114.0.dev)
    • DevTools version 2.35.0-dev.16

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

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

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

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.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
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Community Edition (version 2023.1.4)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

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

[✓] Connected device (4 available)
    • Craig's iPhone 15 (mobile)      • 00008130-0019391C0061401C • ios            • iOS 17.4.1 21E236
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 124.0.6367.119
    ! Error: Browsing on the local area network for Craig's iPhone 11. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this
      Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

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

• No issues found!
@craiglabenz
Copy link
Contributor Author

To whomever first tries to look at this - I am available to pair up and investigate what is going on.

@christopherfujino christopherfujino added the team-tool Owned by Flutter Tool team label May 2, 2024
@christopherfujino
Copy link
Member

cc @andrewkolos

@AbdeMohlbi
Copy link

@craiglabenz
I've observed this behavior myself, when dealing with large trees of nested widgets and complex conditions. Sometimes, even after triggering a hot reload, the changes aren't accurately reflected, especially in deeper parts of the tree. This issue became more noticeable for me around version 3.16.

@borjandev
Copy link

Reproducible on master

[✓] Flutter (Channel master, 3.22.0-23.0.pre.21, on macOS 14.3 23D56 darwin-arm64, locale en-US)
    • Flutter version 3.22.0-23.0.pre.21 on channel master at /Users/m3/fvm/versions/764121cd06
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 764121cd06 (6 hours ago), 2024-05-03 05:58:28 -0400
    • Engine revision 1f9edbeece
    • Dart version 3.5.0 (build 3.5.0-129.0.dev)
    • DevTools version 2.35.0

Hot Restart seems to push the updated code

flutter clean + recompile seemingly updates the state of the code to the point when flutter clean was run.

Changing code and recompiling will now build that state instead rather than the latest state.

This issue is very disruptive as it can easily mislead the developer.

This is especially bad if the developer is trying to fix a difficult bug as it can make him think that his new code is not fixing the bug in question.

@borjandev
Copy link

borjandev commented May 4, 2024

It just happened to me in production!

With fvm flutter build apk

[✓] Flutter (Channel master, 3.22.0-23.0.pre.27, on macOS 14.3 23D56 darwin-arm64, locale en-MK)
    • Flutter version 3.22.0-23.0.pre.27 on channel master at /Users/m2/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c1cafcce12 (10 hours ago), 2024-05-03 22:04:11 +0530
    • Engine revision 837914f378
    • Dart version 3.5.0 (build 3.5.0-130.0.dev)
    • DevTools version 2.35.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/m2/Library/Android/sdk
    • Platform android-34, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

Build took shorter time and installing the release with

adb install build/app/outputs/flutter-apk/app-release.apk

Resulted in an old version being installed on the device.

This is now much more serious @christopherfujino @andrewkolos

Running flutter clean and re-running adb install build/app/outputs/flutter-apk/app-release.apk lead to the correct version being installed.

Same with iOS releases it actually deployed a wrong build!

@timmaffett
Copy link
Contributor

Hot reload/restart definitely is affected also - it no longer works in all cases either - it may seem to work in some cases, but it often no longer works. It does not matter if the debugger is being used or not.

The only way to develop with the current master channel is to ALWAYS flutter clean after ANY change - it is no longer possible to due any hotreloading - you simply can no longer depend on it.

This bug should be of the highest priority - the build environment is essentially totally broken in all cases.

@timmaffett
Copy link
Contributor

This may be related to #147643

@craiglabenz
Copy link
Contributor Author

Great news - that would also mean #147709 should be our fix.

@craiglabenz
Copy link
Contributor Author

craiglabenz commented May 6, 2024

Update: #147709 does seem to fix this broken behavior for me. For anyone on the master channel who wants this know, if you build Flutter from a clone of the repo, checking out this and running flutter doctor will get you this patch immediately.

@timmaffett
Copy link
Contributor

timmaffett commented May 6, 2024

I can confirm that #147709 does fix this issue for me. I have been testing it for the last few hours on several projects and changes I make are being correctly incorporated into builds and hot reloads.

(I applied the changes to my packages/flutter_tools/lib/src/build_system/targets/common.dart file (also adding a debug print statement to the build() method around line 167 so I could verify each build was using the changes))
(Once your common.dart is patched you need to delete the bin/cache directory so that it forces rebuilds of the tools (or running flutter doctor))

Here's to hoping that #147709 gets merged into the master channel ASAP (for others sake - my environment works now 😄 )

This bug was and will continue to be a real time waster for developers on the master channel until it is fixed. It is confusing as heck when changes you are making are not being incorporated into builds!

@andrewkolos
Copy link
Contributor

#147709 has merged, so I believed this issue should be resolved. Feel free to reopen if this is not the case.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team-tool Owned by Flutter Tool team
Projects
None yet
Development

No branches or pull requests

6 participants