Closed
Bug 967119
Opened 10 years ago
Closed 10 years ago
Hold a wake lock while the contacts DB upgrade is running
Categories
(Core Graveyard :: DOM: Contacts, defect, P2)
Core Graveyard
DOM: Contacts
Tracking
(Not tracked)
RESOLVED
FIXED
1.4 S2 (28feb)
People
(Reporter: reuben, Assigned: reuben)
References
Details
(Keywords: perf, Whiteboard: [c=progress p= s= u=], [systemsfe])
Attachments
(1 file, 4 obsolete files)
1.22 KB,
patch
|
reuben
:
review+
|
Details | Diff | Splinter Review |
Ben suggested doing this in bug 951806, and it's a great idea. The upgrade can take a long time for large databases and letting the phone sleep can cause it to take a ridiculously long time (Ben says he experienced a 30min long upgrade on his phone).
Updated•10 years ago
|
Assignee | ||
Comment 1•10 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=a5c96a67973b
Assignee | ||
Updated•10 years ago
|
Attachment #8369745 -
Flags: review?(anygregor)
Comment 2•10 years ago
|
||
How did you test this? Does this even work? Isn't that async and we call unlock right away? I think you have to wait for the transaction to complete.
Assignee | ||
Comment 3•10 years ago
|
||
"Probably not". I then realized I don't even need anything special in IndexedDBHelper.
Attachment #8369745 -
Attachment is obsolete: true
Attachment #8369745 -
Flags: review?(anygregor)
Attachment #8371044 -
Flags: review?(anygregor)
Updated•10 years ago
|
Whiteboard: [c=progress p= s= u=] → [c=progress p= s= u=], [systemsfe]
Comment on attachment 8371044 [details] [diff] [review] Hold a CPU lock while the upgrade is running Review of attachment 8371044 [details] [diff] [review]: ----------------------------------------------------------------- Stealing from gwagner at his request. ::: dom/contacts/fallback/ContactDB.jsm @@ +767,5 @@ > + this.cpuLock = Cc["@mozilla.org/power/powermanagerservice;1"] > + .getService(Ci.nsIPowerManagerService) > + .newWakeLock("cpu"); > + > + aTransaction.oncomplete = function() { It's not clear that this will always be safe. IndexedDBHelper could some day set the oncomplete handler for this transaction and then your code would silently replace it. I'd recommend using addEventListener instead. Also, you're not handling abort here. If the transaction fails you'll never release the cpu lock. I'd recommend making a common (local) cleanup function and then adding event listeners for "complete" and "abort" types.
Attachment #8371044 -
Flags: review?(anygregor) → review-
Updated•10 years ago
|
Target Milestone: --- → 1.4 S1 (14feb)
Assignee | ||
Comment 5•10 years ago
|
||
(In reply to ben turner [:bent] <vacation until 2/14> (use the needinfo? flag!) from comment #4) > It's not clear that this will always be safe. IndexedDBHelper could some day > set the oncomplete handler for this transaction and then your code would > silently replace it. I'd recommend using addEventListener instead. We should probably make IDBHelper use addEventListener too. > Also, you're not handling abort here. If the transaction fails you'll never > release the cpu lock. > > I'd recommend making a common (local) cleanup function and then adding event > listeners for "complete" and "abort" types. Do you mean "error"? And probably "blocked" too.
Assignee | ||
Comment 6•10 years ago
|
||
Attachment #8371044 -
Attachment is obsolete: true
Attachment #8373008 -
Flags: review?(bent.mozilla)
Comment on attachment 8373008 [details] [diff] [review] Hold a CPU lock while the upgrade is running, v2 Review of attachment 8373008 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/contacts/fallback/ContactDB.jsm @@ +776,5 @@ > + } > + > + aTransaction.addEventListener("complete", unlockCPU); > + aTransaction.addEventListener("error", unlockCPU); > + aTransaction.addEventListener("blocked", unlockCPU); No, I meant 'abort', not 'error' or 'blocked' :) You're adding event listeners to a transaction, not to a request. Error events bubble up from requests to the transaction but in general those should be handled by other code. Blocked events are only delivered to open requests, so they'll never be seen by your code here.
Attachment #8373008 -
Flags: review?(bent.mozilla) → review-
Assignee | ||
Comment 8•10 years ago
|
||
(In reply to ben turner [:bent] (use the needinfo? flag!) from comment #7) > You're adding event listeners to a transaction, not to a request. Ah, yes. I was looking at the wrong docs.
Attachment #8373008 -
Attachment is obsolete: true
Attachment #8379348 -
Flags: review?(bent.mozilla)
Comment on attachment 8379348 [details] [diff] [review] Hold a CPU lock while the upgrade is running, v3 Review of attachment 8379348 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/contacts/fallback/ContactDB.jsm @@ +800,5 @@ > + > + function unlockCPU() { > + if (outer.cpuLock) { > + if (DEBUG) debug("unlocking cpu wakelock"); > + outer.cpuLock.unlock(); You might as well set outer.cpuLock to null here too, right?
Attachment #8379348 -
Flags: review?(bent.mozilla) → review+
Assignee | ||
Comment 10•10 years ago
|
||
Carrying r=bent.
Attachment #8379348 -
Attachment is obsolete: true
Attachment #8380224 -
Flags: review+
Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Comment 11•10 years ago
|
||
https://hg.mozilla.org/integration/b2g-inbound/rev/3db93067735a
Keywords: checkin-needed
Updated•10 years ago
|
Target Milestone: 1.4 S1 (14feb) → 1.4 S2 (28feb)
Comment 12•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/3db93067735a
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•