Closed Bug 1534208 Opened 6 years ago Closed 6 years ago

LSNG: DOM File thread and PBackground child for it must be created as soon as possible

Categories

(Core :: Storage: localStorage & sessionStorage, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: janv, Assigned: janv)

References

Details

Attachments

(1 file)

Latest testing of LSNG with NVDA has revealed that there's still an edge case which leads to a deadlock. I created an experimental patch and according to QA it fixes occasional hangs.
Here's the problem. When localStorage for a content process is accessed for the first time, we need to create the DOM File thread if it doesn't exist and also initialize PBackground on that thread. BackgroundChild::GetOrCreateForCurrentThread is synchronous and happens mostly on the current thread (DOM File thread in this cas). However, last step consists of creating a runnable that must run on the main thread because it needs to send an async message to the parent via PContent, to finish PBackground initialization for the thread. At the same time we block the main thread, so the runnable wouldn't have a chance to run, but we fixed that by passing a nested event queue/target to BackgroundChild::GetOrCreateForCurrentThread.
Anyway, it can happen, that at the same time, the main process is issuing a synchronous call to the content process on the main thread, so the async IPC message that was sent from content to finish PBackground initialization can't be handled because of the sync call. As I mentioned, we block the main thread in the content process, so this all leads to a deadlock.
I think we can mitigate this by creating DOM File thread and PBackground child in advance.

Blocks: 1517090
Assignee: nobody → jvarga
Priority: -- → P1

I am seeing this on Mobile Twitter and Facebook, primarily after updating Nightly and a first access of a restored tab for these applications. As I also commented in bug 1516136 comment #30.

Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/52b03bc34899 LSNG: DOM File thread and PBackground child for it must be created as soon as possible; r=asuth
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: