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

potential improvement for responsiveness in FBReaderJ #185

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@yulin2

yulin2 commented Feb 16, 2014

Dear developers of FBReaderJ,

I'm a Ph.D. student and I'm doing research related to Android apps'
responsiveness. I found there are some cases in FBReaderJ that the
database is queried, or bitmap is generated in UI thread. Does this
affect the responsiveness of the app? An optimization could be
extracting these operations into AsyncTask.

For example, in ImageViewActivity.java, line 78 generates a bitmap
(invokes "getImageData"), which is a long computation. Is it better to
put them into a AsyncTask, so the onCreate method won't be blocked? I
attach a sample patch here. Note that there are data races on
"myBitmap" after this change, but I think the races won't lead to bugs
because you've checked if "myBitmap" is null before use it in "onDraw"
method.

Similarly, I also transformed ZLAndroidPaintContext.java,
BookInfoActivity.java, NetworkBookInfoActivity.java, since they are
also trying to get Bitmap in UI thread.

Also, in BookInfoActivity.java and LibraryActivity.java, there are
several access to IO/database in UI Thread. E.g.,
BookInfoActivity.java line 116 invokes "myBook.reloadInfoFromFile()".
This also lead to a potential responsiveness issue. Thus, I tried to
move it into AsyncTask. Similarly, LibraryActivity.java invokes
"myRootTree.Collection.saveBook" several times, which executes a
database transaction.

There should be some other places that can be improved. I can't report
all of them since I checked the code manually and it takes time. However,
what do you think about these improvements? My thought is we can improve the
responsiveness if we try to avoid the access to IO/Database, computing bitmap in
UI thread.

Thanks,
Yu

@yulin2

This comment has been minimized.

Show comment
Hide comment
@yulin2

yulin2 Mar 4, 2014

Hello developers of FBReaderJ,

I sent these patches two weeks ago. Do you have any comments on them? Will the refactorings improve the responsiveness of FBReaderJ.

Thanks,
Yu

yulin2 commented Mar 4, 2014

Hello developers of FBReaderJ,

I sent these patches two weeks ago. Do you have any comments on them? Will the refactorings improve the responsiveness of FBReaderJ.

Thanks,
Yu

@geometer

This comment has been minimized.

Show comment
Hide comment
@geometer

geometer Mar 6, 2014

Owner

Hi, thanks for the patch. Sorry, these days I was far away from FBReader development. Will review your update ASAP. Looks like it's a good improvement, but I think it's necessary to check all points if async execution does not cause any unexpected issues.

Regards,

-- Nikolay

Owner

geometer commented Mar 6, 2014

Hi, thanks for the patch. Sorry, these days I was far away from FBReader development. Will review your update ASAP. Looks like it's a good improvement, but I think it's necessary to check all points if async execution does not cause any unexpected issues.

Regards,

-- Nikolay

@boussouira

This comment has been minimized.

Show comment
Hide comment
@boussouira

boussouira Mar 14, 2014

Contributor

Hi,
Take a look at: http://developer.android.com/reference/android/os/StrictMode.html
it may help you in your research, it report long task that run on UI thread.

Yours,
Ahmed

Contributor

boussouira commented Mar 14, 2014

Hi,
Take a look at: http://developer.android.com/reference/android/os/StrictMode.html
it may help you in your research, it report long task that run on UI thread.

Yours,
Ahmed

@yulin2

This comment has been minimized.

Show comment
Hide comment
@yulin2

yulin2 Mar 15, 2014

Thanks Ahmed! StrictMode is helpful to detect potential long-running operations.

yulin2 commented Mar 15, 2014

Thanks Ahmed! StrictMode is helpful to detect potential long-running operations.

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