-
Notifications
You must be signed in to change notification settings - Fork 294
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
"Reloaded 0 of NNN libraries in Xms" #450
Comments
I'm reasonably sure that output also appears on Hot Reload from the command line, so this should be asked on the main Flutter repo. The reason you're seeing so many 0 events could be that the changes you made didn't affect the current state of the running app. I could be mistaken though. |
This output does come from Flutter. My guess is that there's nothing to reload (Dart Code doesn't reliably know when a reload is required or not, though if it's expensive to "do nothing" possibly we could try and skip the command for obvious cases where nothing has changed). I think your suggested text is much better (assuming it's accurate - 300ms does seem a long time to do nothing) so worth raising against the flutter or SDK repos (I don't know how the code is split for these things). |
Great, thanks. I'll move this over! |
It's also possible my save-detection is kind aggressive - any file saved will trigger it, since I don't know if I can reliably tell which files might affect it (for ex. if I only did Dart files, what if you have some resource file? I'm not familiar enough with hot reload/Flutter to know what the rules are). To be honest, having a line of output on every single file save might be a bit spammy, so maybe this needs handling better anyway. Maybe it the hot reload was initiated by a save and starts "Reloaded 0 of" I should suppress the output? |
Filed @ flutter/flutter#13187. Yeah, maybe it makes sense to suppress (or rewrite) "0 of " messages, but I'll wait and see what the folks at flutter/flutter#13187 say. In this particular case, the files I were modifying were not reachable from /cc @devoncarew |
Yup, this text comes from flutter_tools. Definitely agree that the text IntelliJ works a bit differently wrt saving files. It auto-saves changes, and cmd-s is mapped to 'save all', not file save. Possibility because of this, we found that users developed a mental model of 'cmd-s == reload'. The IntelliJ plugin did have more change detection in terms of sets of changes that wouldn't effect the running app - we wouldn't reload in those cases. This ended up being too unpredictable for users - sometimes cmd-s would reload, and sometimes it wouldn't. We ended up simplifying to having cmd-s always reload. |
Sounds like Dart Code probably isn't too dissimilar to IntelliJ then, though now I'm thinking if you turn auto-save on in Code you'll get super-spammy reloading. I'll add a case to check that. I'm not sure how to best fix that though - I can't go re-binding the save key and even if I can tell the difference between auto/manual save, I can't skip it since the user might be wanting the reload. @devoncarew Is there any possibility of making this message not just go to stdout so I can handle it better (eg. show it on the status bar or something) to reduce the spam? |
If it is an issue, you could just not reload on save if they have auto-save enabled. We are able to detect the difference between an auto-save and a manual one in IntelliJ. Very early UX reviews of reload-on-save did turn up that you really only want to reload on some explicit user action. So reloading the app just because you switched apps and IntelliJ lost focus (and triggered an auto-save), was unexpected and not desired :)
I think its useful for the user to know when a reload happened, and some bits of data about the reload. IntelliJ actually clears the console between reloads in order to help bookend each reload. So, instead of trying to regex out the message in order to reduce console spam, I think I'd first look at ways of making reload-on-save less spammy. Not 100% clear when those would be occurring, but if saves are happening very frequently together - on the same file or multiple - you could debounce that a bit with a few hundred ms delay. |
What happens if the user makes a change; auto-save fires, then the user wants to hot reload? In Code, I don't think hitting Ctrl+S would do anything (it'd bail out early because there's nothing to save). That could also be frustrating :( |
I also encountered a similar problem.The problem I finally found it is that the path has two slashes when importing, like below: |
@HengCC I don't know if it matches your issue, but I found some strange behaviour with two slashes which I've opened an issue about at flutter/flutter#29909. |
Use IDEA to import files automatically, and find this line in the header
Change code to And then the hot reload works, I found the problem caused by IDEA for 2 hours |
I spend a half-day to find out "why flutter hot reload not working?". after change imports, we need to clean flutter caches. Thanks Men. |
I guess that after reading from the local file, the flutter reads the cache from memory every time, so no matter how the file changes, it cannot hot reload |
After Flutter Clean, Hot Reload work. |
Where to fix it |
At the very top of your main.dart there is an import statement. |
This might come straight from observatory, in which case I can move.
I ❤️ the new "reload-on-save" feature, but I think the output emitted is pretty confusing:
I ask myself the following questions when reading this output:
I think it might be more friendly to either say:
etc. Again, I'm not 100% sure what this means :)
The text was updated successfully, but these errors were encountered: