Using SDKs? Here’s How They Could Slow Your App Start Time

15
Using SDKs? Here’s how they could Slow your App Start Time

Transcript of Using SDKs? Here’s How They Could Slow Your App Start Time

Page 1: Using SDKs? Here’s How They Could Slow Your App Start Time

Using SDKs? Here’s how they could Slow your App Start Time

Page 2: Using SDKs? Here’s How They Could Slow Your App Start Time

TABLE OF CONTENTS

App launch time definition

The onCreate complexity

Waiting for the other shoe to drop

The good, the bad and the unzipped

Check yourself before you wreck yourself

What should you do?

Page 3: Using SDKs? Here’s How They Could Slow Your App Start Time

APP LAUNCH TIME DEFINITION

There is a time frame between the app’s class’s onCreate and the launcher activity’s onStart.

onStart

(Opening

screen seen)

App launch timeonCreate

Page 4: Using SDKs? Here’s How They Could Slow Your App Start Time

This time frame can be a few milliseconds

BUT…

It can also get to as much as several seconds!

Page 5: Using SDKs? Here’s How They Could Slow Your App Start Time

THE onCreate COMPLEXITY

Most SDKs aim to be placed in the application’s onCreate to get into gearat the earliest possible time

However, those SDKs might block the main UI, which forces your users to wait longerwithout any indication that your app is responding…

Page 6: Using SDKs? Here’s How They Could Slow Your App Start Time

WAITING FOR THE OTHER SHOE TO DROP

The longest potential task is

pre-loading data from a server

Thankfully, Android doesn’t allow network communicationon the main UI thread

Page 7: Using SDKs? Here’s How They Could Slow Your App Start Time

WAITING FOR THE OTHER SHOE TO DROP

And still, Some SDKs make sure their data has been received from theserver by waiting for a callback before ‘releasing’ the main thread back to the application itself.

When the amount of work done by an SDK depends on network

connection, the best thing to do is NOT to place it in the onCreate

Page 8: Using SDKs? Here’s How They Could Slow Your App Start Time

When the 65K limit was an issue, SDKs were trying to avoid it by loading additional code during Runtime

Even though the 65K issue was resolved, some SDKs never changed the way they work

THE GOOD, THE BAD AND THE UNZIPPED

The result: a long duration of app’s start time due to theadditional code loading

Page 9: Using SDKs? Here’s How They Could Slow Your App Start Time

Real-life scenario: The app code is only responsible for a third of its start time! The rest is spent on SDKs.

Why? SDKs unzip and load dex files dynamically when the app is launched

The following chart displays the distribution of an app start time by its SDKs

THE GOOD, THE BAD AND THE UNZIPPED

Page 10: Using SDKs? Here’s How They Could Slow Your App Start Time

CHECK YOURSELF BEFORE YOU WRECK YOURSELF

The following chart displays the same app’s start time distribution, this time after several usages

Why did one SDK start time shrink while another didn’t?

Look at the difference between the Orange SDK and the Blue one

Page 11: Using SDKs? Here’s How They Could Slow Your App Start Time

CHECK YOURSELF BEFORE YOU WRECK YOURSELF

The Orange SDK first checks if it has already unzipped the file. If so, it only loads the dex file.

However, the Blue SDK unzips the file every single time the app is loaded.

EVERY SINGLE TIME….

Page 12: Using SDKs? Here’s How They Could Slow Your App Start Time

1. Move the entire SDK’s initialization code to a splashscreen or alike

WHAT SHOULD YOU DO?

Page 13: Using SDKs? Here’s How They Could Slow Your App Start Time

SafeDK’s Marketplace is just the place to look for the optimal SDK for you

Replace that SDK with a similar one that offers the same functionality but with less consequences to the user experience.

WHAT SHOULD YOU DO?

2.

Page 14: Using SDKs? Here’s How They Could Slow Your App Start Time

.

3. Not sure why it takes your app so long to launch? Suspect it might be one of the 3rd

party tools you are using but not sure which?

Sign up for SafeDK’s In-App Protection andget SDK-oriented live data and real time alerts for any increase in SDK start time orother issues.

WHAT SHOULD YOU DO?