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

"Reloaded 0 of NNN libraries in Xms" #450

Closed
matanlurey opened this issue Nov 23, 2017 · 17 comments
Closed

"Reloaded 0 of NNN libraries in Xms" #450

matanlurey opened this issue Nov 23, 2017 · 17 comments

Comments

@matanlurey
Copy link

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:

Launching lib/main.dart on iPhone SE in debug mode...
Reloaded 0 of 466 libraries in 410ms.
Reloaded 0 of 466 libraries in 303ms.

I ask myself the following questions when reading this output:

  • Does it mean the reload failed?
  • Does it mean that my save didn't require reloading any libraries?
  • Why did it take 300ms to do nothing?

I think it might be more friendly to either say:

"No libraries required reloading (0 of 466 in 303ms)."
"Reload successful but no libraries reload (...)"

etc. Again, I'm not 100% sure what this means :)

@Skylled
Copy link
Contributor

Skylled commented Nov 23, 2017

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.

@DanTup
Copy link
Member

DanTup commented Nov 23, 2017

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).

@matanlurey
Copy link
Author

Great, thanks. I'll move this over!

@DanTup
Copy link
Member

DanTup commented Nov 23, 2017

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.

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?

@matanlurey
Copy link
Author

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 lib/main.dart. I don't know if IntelliJ handles this differently.

/cc @devoncarew

@devoncarew
Copy link
Contributor

Yup, this text comes from flutter_tools.

Definitely agree that the text Reloaded 0 of 466 libraries in 410ms. is too mechanical and could use clarifying for the n=0 case.

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.

@DanTup
Copy link
Member

DanTup commented Nov 24, 2017

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?

@devoncarew
Copy link
Contributor

though now I'm thinking if you turn auto-save on in Code you'll get super-spammy reloading

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 :)

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?

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.

@DanTup
Copy link
Member

DanTup commented Nov 26, 2017

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.

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 :(

@HengCC
Copy link

HengCC commented Mar 22, 2019

I also encountered a similar problem.The problem I finally found it is that the path has two slashes when importing, like below:
import 'src/decorate_box//box.dart';
change to import 'src/decorate_box/box.dart';
then it's working.

@DanTup
Copy link
Member

DanTup commented Mar 25, 2019

@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.

@Tyrone2333
Copy link

Use IDEA to import files automatically, and find this line in the header

import 'file:///E:/enzo/code/flutter/yd_xuantao/lib/ui/page/profile/my_team_page/my_team_page.dart';

Change code to
import 'package:ydxuantao/ui/page/profile/my_team_page/my_team_page.dart';

And then the hot reload works, I found the problem caused by IDEA for 2 hours

@vishwajit76
Copy link

Use IDEA to import files automatically, and find this line in the header

import 'file:///E:/enzo/code/flutter/yd_xuantao/lib/ui/page/profile/my_team_page/my_team_page.dart';

Change code to
import 'package:ydxuantao/ui/page/profile/my_team_page/my_team_page.dart';

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?".
only you know why?

after change imports, we need to clean flutter caches.
it worked very well.

Thanks Men.

@Tyrone2333
Copy link

Use IDEA to import files automatically, and find this line in the header

import 'file:///E:/enzo/code/flutter/yd_xuantao/lib/ui/page/profile/my_team_page/my_team_page.dart';

Change code to
import 'package:ydxuantao/ui/page/profile/my_team_page/my_team_page.dart';
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?".
only you know why?

after change imports, we need to clean flutter caches.
it worked very well.

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

@vishwajit76
Copy link

Use IDEA to import files automatically, and find this line in the header

import 'file:///E:/enzo/code/flutter/yd_xuantao/lib/ui/page/profile/my_team_page/my_team_page.dart';

Change code to
import 'package:ydxuantao/ui/page/profile/my_team_page/my_team_page.dart';
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?".
only you know why?
after change imports, we need to clean flutter caches.
it worked very well.
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.

@bxTruong
Copy link

bxTruong commented Apr 7, 2021

Use IDEA to import files automatically, and find this line in the header

import 'file:///E:/enzo/code/flutter/yd_xuantao/lib/ui/page/profile/my_team_page/my_team_page.dart';

Change code to
import 'package:ydxuantao/ui/page/profile/my_team_page/my_team_page.dart';

And then the hot reload works, I found the problem caused by IDEA for 2 hours

Where to fix it

@al3sha
Copy link

al3sha commented Apr 19, 2021

Use IDEA to import files automatically, and find this line in the header

import 'file:///E:/enzo/code/flutter/yd_xuantao/lib/ui/page/profile/my_team_page/my_team_page.dart';

Change code to
import 'package:ydxuantao/ui/page/profile/my_team_page/my_team_page.dart';
And then the hot reload works, I found the problem caused by IDEA for 2 hours

Where to fix it

At the very top of your main.dart there is an import statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants