Repository navigation
Flutter seemingly not pushing new dev builds without first running flutter clean #147752
Description
Activity
To whomever first tries to look at this - I am available to pair up and investigate what is going on.
cc @andrewkolos
@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.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.0Hot Restart seems to push the updated code
flutter clean+ recompile seemingly updates the state of the code to the point whenflutter cleanwas 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.
Reacted by Fabio SuarezIt 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.apkResulted in an old version being installed on the device.
This is now much more serious @christopherfujino @andrewkolos
Running
flutter cleanand re-runningadb install build/app/outputs/flutter-apk/app-release.apklead to the correct version being installed.Same with iOS releases it actually deployed a wrong build!
Reacted by Fabio SuarezHot 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 cleanafter 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.
Reacted by Victor Eronmosele and Mohellebi AbdessalemThis may be related to #147643
Great news - that would also mean #147709 should be our fix.
Reacted by Mohellebi AbdessalemUpdate: #147709 does seem to fix this broken behavior for me. For anyone on the
masterchannel who wants this know, if you build Flutter from a clone of the repo, checking out this and runningflutter doctorwill get you this patch immediately.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.dartfile (also adding a debug print statement to thebuild()method around line 167 so I could verify each build was using the changes))
(Once yourcommon.dartis patched you need to delete thebin/cachedirectory so that it forces rebuilds of the tools (or runningflutter 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!
Reacted by Mohellebi Abdessalem#147709 has merged, so I believed this issue should be resolved. Feel free to reopen if this is not the case.
Reacted by Tim Maffett and Craig LabenzReacted by Mohellebi AbdessalemThis 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 -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on May 21, 2024
Steps to reproduce
I have repeatedly seen
$ flutter runnot 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 cleanhere.Expected results
$ flutter runshould either ship the new app or fail loudly.Actual results
$ flutter runeither 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