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

RESOLVED FIXED in Firefox 67

Status

()

enhancement
P1
normal
RESOLVED FIXED
2 months ago
2 months ago

People

(Reporter: janv, Assigned: janv)

Tracking

Trunk
mozilla67
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox67 fixed)

Details

Attachments

(1 attachment)

Assignee

Description

2 months ago

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.

Assignee

Updated

2 months ago
Blocks: 1517090
Assignee

Updated

2 months ago
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.

Comment 4

2 months ago
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

Comment 5

2 months ago
bugherder
Status: NEW → RESOLVED
Last Resolved: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
You need to log in before you can comment on or make changes to this bug.