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

App startup times are too slow #14504

Closed
tvolkert opened this issue Feb 6, 2018 · 24 comments

Comments

Projects
None yet
10 participants
@tvolkert
Copy link
Contributor

commented Feb 6, 2018

I've received a report from an internal Google customer who's evaluating Flutter that they were seeing an initial black screen at first app startup that lasted for about a second -- even in release mode running a simple internal "hello flutter" app (the simple stock counter app).

This was observed on a Nexus 5 running android 6.0.

This is fairly commensurate with the data we see on the performance dashboard, where complex layout benchmark for app startup time is around 800ms, and the gallery startup time is about 1s.

A stock Android app is typically much quicker to first frame. I didn't see an issue filed about this already -- feel free to de-dup is there is.

@eseidelGoogle

This comment has been minimized.

Copy link
Contributor

commented Feb 6, 2018

Is this a regression?

@jason-simmons

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2018

Also see #14502

@jason-simmons

This comment has been minimized.

Copy link
Contributor

commented Feb 10, 2018

It looks like most of the time during startup is being spent in the ResourceExtractor, specifically in calls to AssetManager.list().

ResourceExtractor is now doing a full traversal of the AssetManager tree and calling AssetManager.list() on each entry. This takes a lot of time on the Nexus 5, and it's doing this work even if the assets had already been extracted on a previous run of the app.

See #14491

@mravn-google @szakarias

@eseidelGoogle

This comment has been minimized.

Copy link
Contributor

commented Feb 10, 2018

We track startup times in our benchmarks. Did the AssetManager changes of late cause movement in those? If not, do we need to fix our benchmarks? :)

@jason-simmons

This comment has been minimized.

Copy link
Contributor

commented Feb 10, 2018

Performance of AssetManager.list() seems to be highly variable between devices and/or Android releases.

On the Nexus 5 (with Android 6.0.1), doing this traversal for Gallery takes 3100 msecs (on a repeated run where the assets have already been extracted).

On a Moto G4 (with Android 7.0), the same thing takes only 60 msecs.

@szakarias can the engine avoid extracting each asset up front and instead read assets out of the APK on demand with NDK AssetManager APIs?

@szakarias

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2018

I will take a look at this.

@szakarias

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2018

I've landed (and rolled) a change flutter/engine#4742 so that user defined assets are now read out of the APK instead of being extracted up front and we don't use AssetManager.list() anymore. I've tried it out on different devices and I see a significant performance improvement so I'll close this issue. Please reopen if you still experience problems.

@szakarias szakarias closed this Mar 6, 2018

Milestone 3 automation moved this from A sane asset system (sarah) to Done Mar 6, 2018

@Hixie Hixie removed this from Done in Milestone 3 Mar 7, 2018

@newfivefour

This comment has been minimized.

Copy link

commented Mar 31, 2018

This may help #15936 if the newer Gallery app is loading in a significant number of new resources compared to the older Gallery app.

@tvolkert

This comment has been minimized.

Copy link
Contributor Author

commented Apr 1, 2018

flutter/engine#4742 is included in the 0.2.3 release that's currently live on the play store.

@smoan22

This comment has been minimized.

Copy link

commented Apr 28, 2018

It got fixed when i ran it in release mode in my android studio

@itman85

This comment has been minimized.

Copy link

commented Oct 25, 2018

it is faster in release mode, but still seem slower than native app, need to improve a bit to make it faster

@eseidelGoogle

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2018

@itman85 would love to know more about what hardware you're comparing on and what Apps you're comparing. We track startup time of various Flutter apps but would love to know more about your setup.

@itman85

This comment has been minimized.

Copy link

commented Oct 26, 2018

@itman85 would love to know more about what hardware you're comparing on and what Apps you're comparing. We track startup time of various Flutter apps but would love to know more about your setup.

I run flutter counter sample app on motorola nexus 6, i got blank screen about 1s in release mode

@eseidelGoogle

This comment has been minimized.

Copy link
Contributor

commented Oct 26, 2018

@itman85 I would still love to learn more, maybe we should start a new issue for your specific case? It's very possible we have bugs triggered by your specific setup.

https://github.com/flutter/flutter/issues/new

When you say "blank screen for about 1s"? Does that mean the app is launching quickly but then showing blank? Or is that blank screen the application launch animation and it's just slower for Flutter apps than other apps?

@NavidMoshkbar

This comment has been minimized.

Copy link

commented Feb 10, 2019

Hi , I'm new in Flutter.. but i also Developed Android apps with Java in Android studio for 2 years.
but the apps created with java in Android studio are more faster than flutter apps.
one of the most undeniably reasons that I'm saying this is That flutter App running very Slow on First start.
even in Example "futter_app" project when you click on increment button, flutter reacts to it after 1 sec.

  • tested in Google pixel 2 , galaxy s7.
@NavidMoshkbar

This comment has been minimized.

Copy link

commented Feb 10, 2019

@itman85 I would still love to learn more, maybe we should start a new issue for your specific case? It's very possible we have bugs triggered by your specific setup.

https://github.com/flutter/flutter/issues/new

When you say "blank screen for about 1s"? Does that mean the app is launching quickly but then showing blank? Or is that blank screen the application launch animation and it's just slower for Flutter apps than other apps?

i tested it too.. when i want to launch the app... it's opening white Splash Screen,that it takes sometimes for 2 seconds to display the app content. there is no animation , other apps run instantly after clicking on them.. apps that created on Java or React Native, are faster.

  • tested in google Pixel 2 & Samsung Galaxy S7
@eseidelGoogle

This comment has been minimized.

Copy link
Contributor

commented Feb 10, 2019

@NavidMoshkbar That's surprising and concerning. Could you file a new bug with more information? What hardware are you running on. What mode of Flutter? (--debug, --release, --profile)? What version? (flutter doctor output is fine)/

I would not expect it to take 2 seconds to launch the app, and certainly not 1s for a button to respond! Something seems wrong here and I'd like to get to the bottom of it. Thanks!

@NavidMoshkbar

This comment has been minimized.

Copy link

commented Feb 13, 2019

@tvolkert

This comment has been minimized.

Copy link
Contributor Author

commented Feb 13, 2019

@NavidMoshkbar I'm curious what performance characteristics you observe in release mode?

@jmoseley

This comment has been minimized.

Copy link

commented Mar 13, 2019

I'm also seeing slow bootup times. I have zero experience in app development, so I am quick to admit that I might be doing something wrong, but I am getting the white splash screen for > 10 seconds on app boot, running on a Pixel 3.

@kkonevets

This comment has been minimized.

Copy link

commented May 10, 2019

I confirm too, startup time is slow on a simple app, like counter or list view with builder with just 3 rows. Flutter gallery is much faster than regular apps, but why???
I also noted that when list is built first time it is slow, but when I open it again it's fast. Is it caching something? Flutter's gallery is fast always.
Hey, googlers, please explain me why!

@kkonevets

This comment has been minimized.

Copy link

commented May 10, 2019

I confirm too, startup time is slow on a simple app, like counter or list view with builder with just 3 rows. Flutter gallery is much faster than regular apps, but why???
I also noted that when list is built first time it is slow, but when I open it again it's fast. Is it caching something? Flutter's gallery is fast always.
Hey, googlers, please explain me why!

I have found the answer!
When I deploy app throw Android studio in release mode using "play button" it is slow, but if I execute flutter run --release in terminal it is really fast! Why?

@tvolkert

This comment has been minimized.

Copy link
Contributor Author

commented May 10, 2019

It sounds like through Android studio might not be building the app in Flutter's release mode. @devoncarew

@kkonevets

This comment has been minimized.

Copy link

commented May 10, 2019

I confirm too, startup time is slow on a simple app, like counter or list view with builder with just 3 rows. Flutter gallery is much faster than regular apps, but why???
I also noted that when list is built first time it is slow, but when I open it again it's fast. Is it caching something? Flutter's gallery is fast always.
Hey, googlers, please explain me why!

I have found the answer!
When I deploy app throw Android studio in release mode using "play button" it is slow, but if I execute flutter run --release in terminal it is really fast! Why?

It turns out that in Android studio the "play button" is not a release build, but profiling one by default!
If you go Run-> Flutter run ... in release Mode it does the right thing now!
image

So do not use the default green play button on the main panel
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.