Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Conversation

@yulin2
Copy link

@yulin2 yulin2 commented Oct 19, 2014

Hi, I'm doing research on performance for Android apps. I found some event handlers access disk (read/write files, decode bitmap) from UI thread, but Android docs suggest us to avoid such blocking calls in UI thread. Do they lead to any responsiveness issues?

I tried to refactoring by putting them into background tasks. Looking forward to see your comments.

put json loading into background thread.
put picture save into background thread.
put bitmap decoding into background thread.
put bitmap decoding into background.
@yulin2
Copy link
Author

yulin2 commented Oct 30, 2014

I sent this pr several days ago. Any idea/comments?

@brk3
Copy link
Owner

brk3 commented Dec 2, 2014

@yulin2 Sorry for the delay, Github didn't seem to notify me for some reason so never noticed your PR! Looks ok so far, have you noticed any performance increases from this? I'll do some tests this evening.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import for Bitmap

@yulin2
Copy link
Author

yulin2 commented Dec 3, 2014

Thanks for the reply. I didn't measure performance increase from these refactorings. I apply them based Android docs' suggestion: blocking I/O calls (db, disk, bitmap decode) should be in background thread.

I manually tested the changes but didn't get that exception before. That exception is due to data races on "mPhotos" field. onPageSelected is executed before the initialization in onPostExecute. I remove the changes in PhotoViewerActivity.java to avoid such races.

Sorry for the missing import and final keyword. It's because I typed and committed via the Github web interface so I miss them. Now I added them. I may also create a cleaner pr if you think the changes are ok.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants