potential improvement for responsiveness in FBReaderJ#185
Open
yulin2 wants to merge 1 commit intogeometer:masterfrom
Open
potential improvement for responsiveness in FBReaderJ#185yulin2 wants to merge 1 commit intogeometer:masterfrom
yulin2 wants to merge 1 commit intogeometer:masterfrom
Conversation
Author
|
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, |
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 |
Contributor
|
Hi, Yours, |
Author
|
Thanks Ahmed! StrictMode is helpful to detect potential long-running operations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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