Closed
Bug 1197421
Opened 9 years ago
Closed 9 years ago
Incorrect cross thread promise handling in worker thread registration.unregister and WorkerFetchResolver
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla43
Tracking | Status | |
---|---|---|
firefox43 | --- | fixed |
People
(Reporter: catalinb, Assigned: nsm)
References
Details
Attachments
(2 files)
I found two sites where we don't handle promise passing between main thread and worker thread correctly while working on another patch.
https://treeherder.mozilla.org/logviewer.html#?job_id=10640647&repo=try
Assignee | ||
Comment 1•9 years ago
|
||
It would be even better if we could simplify this across the board, which is hard, but worth thinking about if someone has bandwidth.
Reporter | ||
Updated•9 years ago
|
Assignee: catalin.badea392 → nobody
Assignee | ||
Comment 2•9 years ago
|
||
Bug 1197421 - Fix promise release in worker unregister and fetch. r?catalinb
Attachment #8653150 -
Flags: review?(catalin.badea392)
Assignee | ||
Comment 3•9 years ago
|
||
https://reviewboard.mozilla.org/r/17381/#review15465
Catalin, could you push to try again with whatever tests you were running? Thank you.
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → nsm.nikhil
Updated•9 years ago
|
Status: NEW → ASSIGNED
Reporter | ||
Comment 4•9 years ago
|
||
https://reviewboard.mozilla.org/r/17381/#review15465
The fix looks good to me, but unregister still crashes in one of the wpt tests.
https://treeherder.mozilla.org/logviewer.html#?job_id=10928794&repo=try
Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8653150 [details]
MozReview Request: Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
Attachment #8653150 -
Attachment description: MozReview Request: Bug 1197421 - Fix promise release in worker unregister and fetch. r?catalinb → MozReview Request: Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
Assignee | ||
Comment 6•9 years ago
|
||
Bug 1197421 - Fetch resolver uses PromiseWorkerProxy. r?catalinb
Attachment #8656259 -
Flags: review?(catalin.badea392)
Assignee | ||
Comment 7•9 years ago
|
||
Assignee | ||
Comment 8•9 years ago
|
||
Comment on attachment 8653150 [details]
MozReview Request: Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
Get rid of having users dispatch control runnables. It was error prone and
required too much reasoning. It was also possible to end up in a state where
callers would dispatch a WorkerRunnable, which would succeed, so they would not
dispatch a WorkerControlRunnable. Then the worker would stop running,
canceling the runnable, leaving the proxy in an unclean state. Instead, we
AddRef() and add the feature and remove the feature and Release() on Notify().
If callers successfully run a WorkerRunnable they clean the proxy. If not, the
proxy stays alive until the worker switches to Canceling state.
Assignee | ||
Comment 9•9 years ago
|
||
Comment on attachment 8656259 [details]
MozReview Request: Bug 1197421 - Fetch resolver uses PromiseWorkerProxy. r?catalinb
Bug 1197421 - Fetch resolver uses PromiseWorkerProxy. r?catalinb
The logic was very similar and PromiseWorkerProxy is well tested. We defy
convention a bit by calling CleanUp() in another runnable later in time after
resolving the Promise, but it does not violate any invariants.
Assignee | ||
Comment 10•9 years ago
|
||
Comment on attachment 8653150 [details]
MozReview Request: Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
Get rid of having users dispatch control runnables. It was error prone and
required too much reasoning. It was also possible to end up in a state where
callers would dispatch a WorkerRunnable, which would succeed, so they would not
dispatch a WorkerControlRunnable. Then the worker would stop running,
canceling the runnable, leaving the proxy in an unclean state. Instead, we
AddRef() and add the feature and remove the feature and Release() on Notify().
If callers successfully run a WorkerRunnable they clean the proxy. If not, the
proxy stays alive until the worker switches to Canceling state.
Assignee | ||
Comment 11•9 years ago
|
||
Comment on attachment 8656259 [details]
MozReview Request: Bug 1197421 - Fetch resolver uses PromiseWorkerProxy. r?catalinb
Bug 1197421 - Fetch resolver uses PromiseWorkerProxy. r?catalinb
The logic was very similar and PromiseWorkerProxy is well tested. We defy
convention a bit by calling CleanUp() in another runnable later in time after
resolving the Promise, but it does not violate any invariants.
Reporter | ||
Comment 12•9 years ago
|
||
Comment on attachment 8653150 [details]
MozReview Request: Bug 1197421 - Fix promise worker proxy cleanup and update callers. r?catalinb
https://reviewboard.mozilla.org/r/17383/#review16235
lgtm
::: dom/workers/ServiceWorkerClients.cpp:165
(Diff revision 4)
> // operation is happening on the main thread.
Please remove the comment.
Attachment #8653150 -
Flags: review?(catalin.badea392) → review+
Assignee | ||
Comment 13•9 years ago
|
||
Had to move ReleaseObject() into CleanUp() since the Mutex can't be locked when it is destroyed.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=eda57eac9b12
Assignee | ||
Comment 14•9 years ago
|
||
Another run just to be sure
https://treeherder.mozilla.org/#/jobs?repo=try&revision=5c0691661342
Reporter | ||
Comment 15•9 years ago
|
||
Comment on attachment 8656259 [details]
MozReview Request: Bug 1197421 - Fetch resolver uses PromiseWorkerProxy. r?catalinb
https://reviewboard.mozilla.org/r/18127/#review16379
thanks for fixing this. \o/
::: dom/fetch/Fetch.cpp:51
(Diff revision 3)
> -class WorkerFetchResolver final : public FetchDriverObserver,
> +class WorkerFetchResolver final : public FetchDriverObserver
I think we can relax the threadsafe ref-counting of FetchDriverObserver.
The steps for worker fetch requests would be:
1. send a proxy to the main thread
2. create a WorkerFetchResolver
3. OnResponse(End) dispatch a runnable with the proxy back to the worker thread.
This way, WorkerFetchResolver will live only on the main thread.
::: dom/fetch/Fetch.cpp:61
(Diff revision 3)
> - : mWorkerPrivate(aWorkerPrivate)
> + Create(workers::WorkerPrivate* aWorkerPrivate, Promise* aPromise)
Based on the comment above, a normal constructor that asserts main thread would suffice.
::: dom/fetch/Fetch.cpp:301
(Diff revision 3)
> - explicit WorkerFetchResponseEndRunnable(WorkerFetchResolver* aResolver)
> + explicit WorkerFetchResponseEndRunnable(WorkerPrivate* aWorkerPrivate,
Nit: This doesn't need to be explicit anymore.
Pass only the promise proxy back to the worker thread.
Attachment #8656259 -
Flags: review?(catalin.badea392) → review+
Assignee | ||
Comment 16•9 years ago
|
||
(In reply to Cătălin Badea (:catalinb) from comment #15)
> Comment on attachment 8656259 [details]
> MozReview Request: Bug 1197421 - Fetch resolver uses PromiseWorkerProxy.
> r?catalinb
>
> https://reviewboard.mozilla.org/r/18127/#review16379
>
> thanks for fixing this. \o/
>
> ::: dom/fetch/Fetch.cpp:51
> (Diff revision 3)
> > -class WorkerFetchResolver final : public FetchDriverObserver,
> > +class WorkerFetchResolver final : public FetchDriverObserver
>
> I think we can relax the threadsafe ref-counting of FetchDriverObserver.
>
> The steps for worker fetch requests would be:
> 1. send a proxy to the main thread
> 2. create a WorkerFetchResolver
> 3. OnResponse(End) dispatch a runnable with the proxy back to the worker
> thread.
>
> This way, WorkerFetchResolver will live only on the main thread.
>
> ::: dom/fetch/Fetch.cpp:61
> (Diff revision 3)
> > - : mWorkerPrivate(aWorkerPrivate)
> > + Create(workers::WorkerPrivate* aWorkerPrivate, Promise* aPromise)
>
> Based on the comment above, a normal constructor that asserts main thread
> would suffice.
>
> ::: dom/fetch/Fetch.cpp:301
> (Diff revision 3)
> > - explicit WorkerFetchResponseEndRunnable(WorkerFetchResolver* aResolver)
> > + explicit WorkerFetchResponseEndRunnable(WorkerPrivate* aWorkerPrivate,
>
> Nit: This doesn't need to be explicit anymore.
>
> Pass only the promise proxy back to the worker thread.
Filed a followup for making WorkerFetchResolver main thread only. Its not urgent.
Blocks: 1201915
Comment 17•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/3c920d96f600
https://hg.mozilla.org/mozilla-central/rev/34c126018a48
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•