Closed
Bug 926574
Opened 12 years ago
Closed 12 years ago
ANR: SQLite access on main thread when using CursorAdapters
Categories
(Firefox for Android Graveyard :: Data Providers, defect)
Tracking
(firefox25 unaffected, firefox26+ fixed, firefox27 fixed, fennec26+)
RESOLVED
FIXED
Firefox 27
Tracking | Status | |
---|---|---|
firefox25 | --- | unaffected |
firefox26 | + | fixed |
firefox27 | --- | fixed |
fennec | 26+ | --- |
People
(Reporter: jchen, Assigned: sriram)
References
Details
(Whiteboard: [ANR])
Attachments
(1 file)
4.98 KB,
patch
|
lucasr
:
review+
lsblakk
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
I'm not familiar with the code, but it looks like we are using the deprecated CursorAdapter constructor [1] in our code which "results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors". And we do see a number of these ANRs in the wild [2].
[1] http://developer.android.com/reference/android/widget/CursorAdapter.html#CursorAdapter%28android.content.Context,%20android.database.Cursor%29
[2] http://darchons.github.io/anr-analyzer/?files=c/cb/Anr-20130903.jgz,3/3f/Anr-20130910.jgz,b/bd/Anr-20130917.jgz,d/df/Anr-20130924.jgz#f:anr-20130924,l:28 (requires intranet access)
Comment 1•12 years ago
|
||
Look slike all of our HomePage Adapters use this constructor, even the MultiTypeCursorAdapter:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/home/MultiTypeCursorAdapter.java#28
ReadingListAdapter:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/home/ReadingListPage.java#200
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/home/ReadingListPage.java#139
BookmarksListAdapter:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/home/BookmarksListAdapter.java#43
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/home/BookmarksPage.java#80
Lucas, Margaret, Sriram: Any reason we are using this constructor over the "recommended" constructor:
http://developer.android.com/reference/android/widget/CursorAdapter.html#CursorAdapter(android.content.Context,%20android.database.Cursor,%20int)
The docs also talk about using a LoaderManager and CursorLoader, but I see we are using LoadrManagers and CursorLoaders. Do we just need to switch CursorAdapter constructors?
Flags: needinfo?(sriram)
Flags: needinfo?(margaret.leibovic)
Flags: needinfo?(lucasr.at.mozilla)
Assignee | ||
Comment 3•12 years ago
|
||
I guess we could use the third constructor. The first one was used because we weren't using support v4 library's CursorAdapter earlier. Now we've started using the support v4's CursorAdapter and won't have to worry about API 11+.
(Remember the issue with swapCursor() and not available in old phones (11+) and we reverting everything to use support library's? We shall go with the third option now safely).
We should register a content observer though, with the flag: FLAG_REGISTER_CONTENT_OBSERVER
I'll post a patch today.
Flags: needinfo?(sriram)
Comment 4•12 years ago
|
||
(In reply to Sriram Ramasubramanian [:sriram] from comment #3)
> We should register a content observer though, with the flag:
> FLAG_REGISTER_CONTENT_OBSERVER
I saw this in the Javadocs:
"This flag is not needed when using a CursorAdapter with a CursorLoader."
So maybe we could just pass in 0 when we are using a cursor loader.
Assignee | ||
Comment 5•12 years ago
|
||
I felt the same. We are having a observer in our SimpleCursorLoader.
Assignee | ||
Comment 6•12 years ago
|
||
Attachment #816775 -
Flags: review?(mark.finkle)
Comment 7•12 years ago
|
||
Comment on attachment 816775 [details] [diff] [review]
Patch
This is what I would have assumed we'd need to do, but I want more eyes. Handing to Lucas.
Attachment #816775 -
Flags: review?(mark.finkle) → review?(lucasr.at.mozilla)
Comment 8•12 years ago
|
||
Looks like Sriram has this under control. Clearing needinfo.
Flags: needinfo?(margaret.leibovic)
Updated•12 years ago
|
Assignee: nobody → sriram
tracking-fennec: --- → ?
Comment 9•12 years ago
|
||
(In reply to Mark Finkle (:mfinkle) from comment #4)
> (In reply to Sriram Ramasubramanian [:sriram] from comment #3)
>
> > We should register a content observer though, with the flag:
> > FLAG_REGISTER_CONTENT_OBSERVER
>
> I saw this in the Javadocs:
> "This flag is not needed when using a CursorAdapter with a CursorLoader."
>
> So maybe we could just pass in 0 when we are using a cursor loader.
Yep, our custom cursor loader (SimpleCursorLoader) registers a content observer and forces re-load as appropriate.
Flags: needinfo?(lucasr.at.mozilla)
Comment 10•12 years ago
|
||
Comment on attachment 816775 [details] [diff] [review]
Patch
Review of attachment 816775 [details] [diff] [review]:
-----------------------------------------------------------------
Yep.
Attachment #816775 -
Flags: review?(lucasr.at.mozilla) → review+
Assignee | ||
Comment 11•12 years ago
|
||
Comment 12•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 27
Assignee | ||
Comment 13•12 years ago
|
||
Since this caused ANRs, I feel like nominating this for 26.
tracking-firefox26:
--- → ?
The patch in this bug appears to have solved the issues in bug 919234, which is tracking 26. Since a patch there would likely have been uplifted to 26, I would +1 this nomination.
Updated•12 years ago
|
Flags: needinfo?(sriram)
Updated•12 years ago
|
Assignee | ||
Comment 16•12 years ago
|
||
Comment on attachment 816775 [details] [diff] [review]
Patch
[Approval Request Comment]
Bug caused by (feature/regressing bug #): Using old version of the constructor.
User impact if declined: ANRs randomly.
Testing completed (on m-c, etc.): 10/16
Risk to taking this patch (and alternatives if risky): None.
String or IDL/UUID changes made by this patch: None.
Attachment #816775 -
Flags: approval-mozilla-aurora?
Updated•12 years ago
|
Updated•12 years ago
|
Attachment #816775 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Assignee | ||
Comment 17•12 years ago
|
||
Flags: needinfo?(sriram)
Updated•5 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•