systers / FirstAide-Android

FirstAide is a application to help the Peace Corps Volunteers who are victims of sexual harassment.
23 stars 104 forks source link

White Screen is displayed for few seconds on startup. #328

Open pandilladivya opened 7 years ago

pandilladivya commented 7 years ago

A blank white screen is shown for 3-4 seconds on app startup.

mygif

@sandarumk Kindly review the issue and please let me know if i can solve this issue. Thank You :)

sandarumk commented 7 years ago

Before you try to fix it can you identify why does it happens?

pandilladivya commented 7 years ago

@sandarumk

The white/black screen is usually the window background image by default.

The window background is shown while e.g. onCreate() runs and the layouts are being inflated. It can take some time especially if there's a lot of resources that need to be read, decoded and scaled.

We can prevent white screen at startup by adding a splashScreen or by making the theme transparent to the starting activity in the AndroidManifest.xml file

We already have a splashScreen and still there is a problem, so we can make the theme transparent to the starting activity to prevent this white screen at the time of startup.

sandarumk commented 7 years ago

Making the theme transparent will not reduce the time it takes to load. It just prevents the white screen. So it doesn't solve the real problem here. One good solution is that you can go through the code and find an improvement where you can reduce the load time.

pandilladivya commented 7 years ago

Sure....Will definitely look into it :) Thanks for the review!

sandarumk commented 7 years ago

Any update on this?

pandilladivya commented 7 years ago

I'm working on this. Will make an update as soon as possible Sorry for the delay.

harshitagupta30 commented 7 years ago

Hi! @sandarumk @pandilladivya
In my opinion, the right way to implement a splash screen is using the splash view which has to be ready immediately, even before we can inflate a layout file in the splash activity. Since layout file would be visible to the user only after your app has been fully initialized, which is too late. As we want the splash to be displayed only in that small amount of time before the app is initialized.
So, instead of inflating the layout file if we specify our splash screen’s background as the activity’s theme background the issue will be resolved.

harshitagupta30 commented 7 years ago

As I have already resolved the issue. I am submitting the PR. @sandarumk Please review it. :)

sandarumk commented 7 years ago

@harshitagupta30 Welcome to the community. Can you add a gif of your solution you mentioned? In firstAide we value the discussion over the code contribution. So before making a PR it is always good to discuss the pros and cons of the solution you mentioned. Another important thing to remember is since the issue is assigned to Divya, she might be working on it. So before submitting the PR please make sure that you assigned it to yourself or get your solution approved. As I saw in your solution it will replace the white screen with a green screen, but to populate the splash screen it will take time. So there is a little difference with @pandilladivya 's making theme transparent and your solution. We are trying to address this in a lower level where we can try to come up with a solution to reduce the load time. If you read the comments you will see that. If we do not find a solution that way, then let's discuss which is the best solution between yours and hers. But to confirm my understanding please add a gif to your solution here as @pandilladivya has done before. In future, please get an issue assigned to your self before sending the PR. Please read the README file and wiki for further information.

harshitagupta30 commented 7 years ago

@sandarumk Thanks! Apologies! I'll make sure of this in future. PFA the gif for the support. No such green screen is coming when I open the application which can be seen in the gif. videotogif_2017 01 06_13 55 55

sandarumk commented 7 years ago

Then that will actually solve the problem. I will check it and reopen the PR and review.

sandarumk commented 7 years ago

@pandilladivya Hope you are okay with it since the issue is yours?

pandilladivya commented 7 years ago

@sandarumk I have no problem if @harshitagupta30 puts a PR :)

But I dont think this is an apt solution to the problem. It is similar to what I've proposed earlier in this issue. I've gone through the solution which @harshitagupta30 proposed in the PR, She added a drawable resource file, which have a green background and a bitmap of the logo, and made this as the background of the app. She also removed the progress bar. This is not reducing the time it takes to load .Thus not solving the real problem.

sandarumk commented 7 years ago

In that note yes. Sorry I missed the progress bar. So back to our earlier plan. @harshitagupta30 you can help @pandilladivya to come up with a solution for this. If this didn't work out we will try to find the best from both the solutions, as I stated earlier.

harshitagupta30 commented 7 years ago

@sandarumk Can you please help me out in letting know the utility of progress bar here? Also, I didn't get the point of using splash time out of 2500 which is causing the delay.

sandarumk commented 7 years ago

Splash screen including the progress bar is a requirement from the client.

harshitagupta30 commented 7 years ago

Okay. Thanks! :) https://www.bignerdranch.com/blog/splash-screens-the-right-way/ (The link to the article which I read some time back and tried to implement here. @pandilladivya @sandarumk have a look on it. ) But we can't use a progress bar with this so this might not be a correct way to implement splash screen for this particular case. I'll try to find a more apt solution for this.

codingblazer commented 7 years ago

@pandilladivya Maybe you can try figuring out the bottlenecks responsible for this using tools like inline tracing and method tracer. Also you can search for any heavy initializations in onCreate() and reduce them. Removing global objects by inline objects will also help. After all this you may look for all the memory leaks present in app using some tool like leakcanary. https://developer.android.com/topic/performance/launch-time.html

m-murad commented 7 years ago

@codingblazer also issue #356 will reduce the launch time by decreasing the size of image to be loaded for SplashScreen.

pandilladivya commented 7 years ago

@sandarumk I apologize for being late. I was stuck with my university exams and projects.

@codingblazer Thankyou for your suggestion. I have already tried implementing those which are given in developer guide, but did not find a big change in the startup screen :(

codingblazer commented 7 years ago

@sandarumk @pandilladivya Can I give it a try :-)

pandilladivya commented 7 years ago

@codingblazer yeah sure, I have no problem :)

vikasdesale commented 7 years ago

@sandarumk @pandilladivya @codingblazer Can I give it a try :slightly_smiling_face:

sandarumk commented 7 years ago

Any one can suggest a solution and then we all can decide on whether to continue on it or not.

vikasdesale commented 7 years ago

Thank you @sandarumk, I think I got a solution. please look at below given .gif file Devices Used: Micromax A106, Nexus 5
Root Cause: Android will load a blank layout before it loads based on the theme you have set for it. Solution: The solution is to set the theme of the splash activity to a transparent one. Expected Behaviour: 1)Micromax A106(Android 4.4 KitKat API: 19 )

2)Nexus 5X(Android 7.0 Nougat API: 24)

It displays progress bar on Nexus 5X if you not recording UI as given in below image.this is because of many tasks running on UI Thread of emulator.
fix2

Should I send a PR? :slightly_smiling_face:

Thanks and Regards Vikas Desale

pandilladivya commented 7 years ago

@vikasdesale

This solution is already discussed. @harshitagupta30 and me proposed similar solutions, but I think the apt solution would be reducing the launch time. I worked on reducing the launch time but white screen just doesn't seem to disappear :(

ashu-dadhich commented 7 years ago

@sandarumk I have a suggestion. I got the idea from bookMyShow App what the guys did is they first created a drawable in xml inorder to make the white screen disappear and after some time the process bar shows up(we can achieve it by moving to some another fragment and there show the process bar). If you like the idea I can code it up and show it to you.

vaibhavsingh97 commented 7 years ago

It looks like that heavy task is going on the main UI. We can use thread to give priority to the main UI and can load other things on another thread. This will decrease load time and also white screen problem will be solved

manmohansonict commented 6 years ago

i thing solution for this is only to set the windows back ground in the theme of the activity. https://stackoverflow.com/questions/26155028/splash-screen-activity-background-color