-
Notifications
You must be signed in to change notification settings - Fork 56
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
Put invocation to "findGameById" into AsyncTask in GameActivity.java? #84
Comments
Hey, I see that you have some kind of automated static analysis that's finding these performance goofs (see also nolanlawson/Catlog#42). :) Interesting stuff. Is there any way you could tweak your system to automatically submit a pull request to fix the code? Might not be possible in a lot of cases, but in many, you could just insert a new anonymous AsyncTask to replace the direct database call. Food for thought. |
This might also be useful as part of the Android linter. |
I just start looking at how to infer the places where should use concurrency in Android apps. Actually, we had a paper about how to refactored sequential code to use AsyncTask |
The refactoring for KeepScore would be tricky. The "game" and "playerScores" field need to be synchronized if putting line 473 into background (or putting entire "createGame" method into background thread), otherwise there will be data race. One way to fix these races is to add "synchronized" to those methods which access "game" or "playerScores" field. What do you think? Is it worth to do such refactoring? I guess you didn't put line 473 into background thread because it requires lots of synchronization? p.s., we don't have a system to automatically submit a pull request. The tool is used to transform the code only:) |
Dear Developers of KeepScore,
I'm a Ph.D. student and I'm doing research on improving performance
for Android apps.
I find that in KeepScore, there is a method
"GameDBHelper.findGameById" which accesses database. In most cases,
you put the invocation of this method into AsyncTask to improve responsiveness.
(For example, in "findGameFromGameSummary", "exportToSpreadsheet",
"saveBackup" methods of "MainActivity" class).
But in GameActivity class, "onCreate" method invokes "createGame" at
line 124, which also eventually invokes "GameDBHelper.findGameById" at line
473. I'm whondering why don't also put this invocation of "findGameById"
into background thread? Is there any specific reason that prevent you
to use AsyncTask here?
Thanks,
Yu
The text was updated successfully, but these errors were encountered: