Very long startup time - android

I have a simple app, with nothing too fancy going on (essentially just a tab pager and a recycler view). However when I start up my app from the launcher I get an all white screen for ~3 seconds before my ui shows on screen. I have not had this issue with other apps before. Now I am wondering, how can I look into why it is taking so long?
Does Android Studio have anything to help see why my app takes so long to load?
The delay seems to be worse if starting from completely dead. If the program is in recent tasks the white screen only displays for about a quarter of a second or so.

Android Studio provides a couple of tools to help you track down performances. You'll be able to find out if you allocate too many objects on the main thread, or if your XML hierarchy is too complicated etc.

Related

App hangs for several seconds, how to diagnose what methods are causing it?

My app is hanging when returning from one activity back to a ListView activity. I know the ListView is slow and RecyclerView is a better replacement, however I don't think this would be causing complete UI freezing for multiple seconds (I see ListView lag however this hang is 100% unresponsiveness). The hanging is almost always persistent until you close and re-open the app, and ANR is almost always triggered.
I have messed around with TraceView and see a lot of Object.wait() calls taking up CPU time, but I don't know how to interpret that. Where can I go from here?
Edit (more info):
There is a lot going on from SQLite, image loading, rest calls and so on going on in the app and I've been running Strict Mode and fixing issues but nothing shows up in Strict Mode logs when this type of hang happens (which is very reproduceable)
Screenshot of systrace during hang

Android app skipping frames and hanging delay with imageviews

I've created a flashlight app for android which generally runs fine aside from a couple of issues:
When the app first turns on a grey background appears for around 1 second then my app starts, this grey background is nowhere in my app code.
The app has two button imageviews which when clicked switch on the flashlight and change the imageview to the other button state. The app works quick when switching from off state to on, but when going from on to off there is a noticeable one second delay.
Around 31-35 frames are skipped when I press the button to switch from on to off which is where the delay occurs though no skipped frames when switching from off to on.
I've been searching for the solution for around 2 days scanning through systrace and modifying my code but can't seem to figure it out. The application is pretty simple with all the Camera work done using AsyncTask for opening camera and a separate AsyncTask for closing the camera.
Here is my Activity java file:
http://pastebin.com/XVmvZk1N
Here is my Activity xml file:
http://pastebin.com/xxPkuVSA
Here is the systrace log:
http://pastebin.com/v41CPs5X
I would appreciate any help with these issues.
Thank you.

Android app becomes unresponsive to touch

I have an app developed with Sencha Touch and phonegap. At one point, it downloads data from a server and, once it has received a successful response, it displays the next screen. I found, when bundling it up as an iOS app, that it would transition to that next screen, but not display anything, reporting low memory. So I simplified the layout of that next screen (the DOM structure was pretty complex) and it now works on the iOS simulators and on my iPhone.
However, in Android, I can see from the output of my console.log statements that it successfully retrieves the data and fires an event to display the next screen. It then sits around for ages before it displays that screen, even though my console.log statements show that the 'painted' event of that screen has been fired.
Eventually, the screen does show up, but all the controls on the screen are unresponsive to touch. Is it likely that I need to simplify the structure of that screen still further? As the iOS version received a low memory warning before I simplified the page structure, I suspect the Android version may have a similar problem, but I don't know how to monitor memory usage. In the Android version, shortly before the screen does eventually display I see the following in logcat:
UpdateFrameCache: pending style recalc, ignoring
And on the screen which is unresponsive, when I tap some (but not all) of the unresponsive controls, I see:
Got ACTION_DOWN but still waiting on stale event. Catching up.
Eventually, the app will just close itself, with:
Fatal signal 11 (SIGSEGV) at 0xbbbadbeef (code = 1)
Any help gratefully received.
If you perform intensive computations in the UI thread, it might explain why it takes so long.
Try using AsyncTask or a Service if you have some backgorund computations to do. Once they are done, update the interface in the UI thread.
Gordak

Does number of Activities matter in Android App?

I am developing an Android app. I have already crossed more than 20 Activities. So I am bit concerned about it. I mean if there are more Activities in an Android app, does it affect the performance of App like Speed, Memory or any other issue?
Though it is not a standard question but still I feel its something which might help others too
Yes Suraj more activities will affect performance
An activity is the equivalent of a Frame/Window in GUI toolkits. It takes up the entire drawable area of the screen (minus the status and title bars on top). Activities are meant to display the UI and get input from the user
An Activity (calling-Activity) can spawn another Activity (sub-Activity) in 2 ways:
Fire and forget – create an event (Intent) and fire it
Async callback – create an event (Intent), fire it, and wait for it’s response in a callback method (of the calling-Activity).
So the effect of activities will depend on performance of your device, its processor and memory etc.
Even if any activity will remain in stack and not finish then it affects device performance.
Even you have to take a look at security measures.

Screen goes black then program crashes

I have a problem i have been hunting down for the last day and i cant seem to find what is wrong. I have been working on this app for about a month without too many problems. I started working on the main interface page and one button into it this problem rears its ugly head. The problem is the screen shows up and then disappears about 30 seconds later. After watching the error it has a particular method of things happening. First my bitmaps go, then the texts after about a second, then the screen is black for about 5 seconds, then i get my phone background then about 10 seconds later the my apps show up. I never get a force close message. Id rather understand what is causing the problem then having someone tell me to change something so i can prevent it from happening again. So i don't want to post my code just yet.
other tidbits:
all my graphics are using the canvas method
since i got a 30 second window i continued working on the framework of my project the problem still has the same timing after finishing a good portion of it
the graphics i used from the working portion of my code are the same in my nonworking
the screen has no functionality to it right now its just graphics
I get the feeling i cant avoid posting my code but please try to answer it without asking for it.
Thanks to Steve for letting me know about the logcat. After updating Eclipse it became much easier to read. The problem was, not enough garbage collecting. Ironically the code that seem to be giving me problems was not the problem it was just the straw that broke the camels hump.
I have chopped up my code enough to where it is workable but i still have a lot ahead of me to fix the issue 100%.

Categories

Resources