Closed Bug 746362 Opened 8 years ago Closed 8 years ago

StrictMode violation in saving Sync migration state

Categories

(Firefox for Android :: General, defect)

ARM
Android
defect
Not set

Tracking

()

RESOLVED FIXED
Firefox 14

People

(Reporter: gcp, Assigned: gcp)

References

Details

Attachments

(1 file)

Saving the Preference means hitting disk in the main thread:

D/StrictMode(14963): StrictMode policy violation; ~duration=39 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=31 violation=2
D/StrictMode(14963): 	at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1067)
D/StrictMode(14963): 	at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:235)
D/StrictMode(14963): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
D/StrictMode(14963): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:77)
D/StrictMode(14963): 	at android.app.SharedPreferencesImpl.createFileOutputStream(SharedPreferencesImpl.java:521)
D/StrictMode(14963): 	at android.app.SharedPreferencesImpl.writeToFile(SharedPreferencesImpl.java:569)
D/StrictMode(14963): 	at android.app.SharedPreferencesImpl.access$800(SharedPreferencesImpl.java:47)
D/StrictMode(14963): 	at android.app.SharedPreferencesImpl$2.run(SharedPreferencesImpl.java:489)
D/StrictMode(14963): 	at android.app.SharedPreferencesImpl.enqueueDiskWrite(SharedPreferencesImpl.java:510)
D/StrictMode(14963): 	at android.app.SharedPreferencesImpl.access$100(SharedPreferencesImpl.java:47)
D/StrictMode(14963): 	at android.app.SharedPreferencesImpl$EditorImpl.commit(SharedPreferencesImpl.java:432)
D/StrictMode(14963): 	at org.mozilla.gecko.ProfileMigrator.setMigratedSync(ProfileMigrator.java:362)
D/StrictMode(14963): 	at org.mozilla.gecko.ProfileMigrator$SyncTask$3.onPostExecute(ProfileMigrator.java:527)
D/StrictMode(14963): 	at org.mozilla.gecko.ProfileMigrator$SyncTask$3.onPostExecute(ProfileMigrator.java:522)
D/StrictMode(14963): 	at android.os.AsyncTask.finish(AsyncTask.java:590)
D/StrictMode(14963): 	at android.os.AsyncTask.access$600(AsyncTask.java:149)
D/StrictMode(14963): 	at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:603)
D/StrictMode(14963): 	at android.os.Handler.dispatchMessage(Handler.java:99)
D/StrictMode(14963): 	at android.os.Looper.loop(Looper.java:132)
D/StrictMode(14963): 	at android.app.ActivityThread.main(ActivityThread.java:4126)
D/StrictMode(14963): 	at java.lang.reflect.Method.invokeNative(Native Method)
D/StrictMode(14963): 	at java.lang.reflect.Method.invoke(Method.java:491)
D/StrictMode(14963): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
D/StrictMode(14963): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
D/StrictMode(14963): 	at dalvik.system.NativeStart.main(Native Method)
Depends on: 715550
This is arguably less critical as it will only happen once. But the code that causes it just landed so we might as well fix it now.
Assignee: nobody → gpascutto
Attachment #615934 - Flags: review?(blassey.bugs)
Comment on attachment 615934 [details] [diff] [review]
Patch 1. Save settings in the background thread

Review of attachment 615934 [details] [diff] [review]:
-----------------------------------------------------------------

::: mobile/android/base/ProfileMigrator.java
@@ -502,5 @@
>                          Log.i(LOGTAG, "Migrating Sync account succeeded.");
>                      }
>                      setMigratedSync();
>                  }
> -            }.execute(params);

this was being run on the main UI thread. Is this change intentional and ok?
Attachment #615934 - Flags: review?(blassey.bugs) → review+
Attachment #615934 - Flags: approval-mozilla-central?
>this was being run on the main UI thread. Is this change intentional and ok?

It changed from createSyncAccountTask, which was an AsyncTask, into a Runnable calling the createSyncAccount method in the background thread. None of those ran on the UI thread. 
The preference check was on the main thread, and that's this bug.


So this is intentional and OK.
Attachment #615934 - Flags: approval-mozilla-central? → approval-mozilla-central+
https://hg.mozilla.org/mozilla-central/rev/4ec92164de7b
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 14
You need to log in before you can comment on or make changes to this bug.