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

Question: Why I'm only getting a white screen while the app is starting up? #332

Closed
enchev opened this issue Jan 12, 2016 · 23 comments
Closed
Assignees
Labels

Comments

@enchev
Copy link

enchev commented Jan 12, 2016

From @gaurav-chandra on January 12, 2016 10:11

Why I'm only getting a white screen while the app is starting up? When I click on launcher icon, I get a white screen for sometime and then my application shows.

Copied from original issue: NativeScript/NativeScript#1356

@enchev
Copy link
Author

enchev commented Jan 12, 2016

Is this for Android or iOS? Or both?

@enchev
Copy link
Author

enchev commented Jan 12, 2016

From @gaurav-chandra on January 12, 2016 12:50

I develop for Android so I have checked it for Android only.

@slavchev
Copy link

@gaurav-chandra

Indeed, NativeScript apps could have slow startup. It could be because of the runtime or the app itself. Can you tell us the startup time reported from ActivityManager for the default app created with the following commands?

tns create app1
cd app1
tns platform add android
tns run android --justlaunch

You can find the startup time via the adb logcat command and should look for a line similar the to following one:

I/ActivityManager(XXX): Displayed org.nativescript.app1/com.tns.NativeScriptActivity: +XsXXXms

Also, can you tell us what device/emulator you use?

For splash screen, you can read Splash Screen For Your Android Applications article as well.

@NathanaelA

This comment was marked as abuse.

@gaurav-chandra
Copy link

@slavchev the time is

+4s133ms

@NathanaelA I don't have any major code or cpu intensive task. I just have

exports.navigatingto = function(args) {
    page = args.object;
    //there is a bug so we need to put this here
    page.actionBarHidden=false;
    page.bindingContext = main.$scope;
    main.$scope.set('couponCode',main.couponCode());
    var phoneField = view.getViewById(page,'phoneField');
    //console.dir(phoneField.android);
    var fArray = [];
    fArray[0] = new android.text.InputFilter.LengthFilter(10);
    phoneField.android.setFilters(fArray);
    insomnia.keepAwake().then(function() {
        console.log("Insomnia is active");
    });
};

setTimeout also does not help in my case. Does require() also take time to initialize? Probably if there are no modules to require, I can speed it up.

@NathanaelA

This comment was marked as abuse.

@gaurav-chandra
Copy link

@NathanaelA it is for this app. I wanted to try on the actual app I am building. Yes, there are couple of requires on top of the page.

I don't use an emulator. I directly run on device. Lenovo A6000 with Android 5. I will try by removing and calling requires only when needed.

@gaurav-chandra
Copy link

In the new app here is the log:

I/ActivityManager(  864): Displayed org.nativescript.app1/com.tns.NativeScriptActivity: +3s525ms

@slavchev
Copy link

@gaurav-chandra

I can confirm that ActivityManager reports ~3.5s for the first startup of a new app on a similar class device. And this is a lot of time indeed. The good news is that we work hard to improve application startup time. We built working prototypes that use V8 code caching and custom startup snapshots features. So far, the results are very promising. Right now it is hard to say when we will ship these improvements but I guess we will be ready for one of the coming releases. I will update this issue once I have more news.

@atanasovg
Copy link
Contributor

Just to add some more info here:

  • Significant amount (>1s) of this time is spent in generating the so called "Bindings" - that is the glue code for Java classes extended through JavaScript. You may try to run the tns build android --static-bindings command to pre-generate these.
  • On a second+ application runs the loading time should be considerably faster because the file extraction and binding generation is already performed and cached.

Additionally, we are constantly working on improving the loading time of the {N} modules - for example for the 1.5.1 release we improved the require routine - modules are loaded only when/if needed:
NativeScript/NativeScript#1256

The custom startup snapshots feature mentioned by @slavchev also looks promising - we have a POC and it shows nearly 1s ! improvement. Our target is to reduce the loading time up to a maximum of 1.5 seconds for a first (cold) start.

@NathanaelA

This comment was marked as abuse.

@atanasovg
Copy link
Contributor

@NathanaelA Any research on the matter is more than welcome! Performance, especially the loading time is always with high priority.

@gaurav-chandra
Copy link

Is this being looked into actively by core nativescript developers? Hello world NS app is still way slower than Hello world Native Java Android app.

@NathanaelA

This comment was marked as abuse.

@gaurav-chandra
Copy link

hey @NathanaelA thanks for the clarification. I guess you are right, I can show the splash screen.

@slavchev
Copy link

@gaurav-chandra

Is this being looked into actively by core nativescript developers?

Good news :) Recently @atanasovg merged PR #341. You will hear more details soon.

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Apr 21, 2016

snapshot will optimize loading time:
related to: #425

@alvirtuoso
Copy link

Very Disappointing for some trying to decide if NativeScript is the one to learn. Great features BUT a let-down. Im really excited until i came across this app size prob.

@sipacate
Copy link

@alvirtuoso I wouldn't worry too much about this because it's under development. While the size is larger than we want right now, the pending solutions will address this in short order.

@alvirtuoso
Copy link

alvirtuoso commented May 12, 2016

I wonder if a few of dependencies in the file be in separate thread or web service. I'm no expert but just a thought.

@Plamen5kov
Copy link
Contributor

Loading time is further boosted, because of the static binding generator that now runs by default.

@gaurav-chandra
Copy link

awesome. will give it a try.

@Plamen5kov Plamen5kov self-assigned this Aug 10, 2016
@Plamen5kov
Copy link
Contributor

This is implemented, the app ships with splash by default. More information here: https://github.com/NativeScript/docs/blob/master/publishing/creating-launch-screens-android.md

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

No branches or pull requests

8 participants