Closed
Bug 1224647
Opened 9 years ago
Closed 9 years ago
ImageBitmap code is doing multithreaded stuff with ErrorResult
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla45
Tracking | Status | |
---|---|---|
firefox45 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: kaku)
References
Details
Attachments
(2 files)
That's not supported, and it will completely explode on you depending on what gets thrown on the ErrorResult on the main thread. You need to keep the ErrorResult uses thread-local.
Once this is fixed, I will try to add asserts to that effect to ErrorResult to keep this from being a problem in the future...
Comment hidden (typo) |
Assignee | ||
Comment 2•9 years ago
|
||
Bug 1224647 - remove cross-threads usages of ErrorResult; r?bz
Attachment #8689410 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 3•9 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #0)
> That's not supported, and it will completely explode on you depending on
> what gets thrown on the ErrorResult on the main thread. You need to keep
> the ErrorResult uses thread-local.
>
> Once this is fixed, I will try to add asserts to that effect to ErrorResult
> to keep this from being a problem in the future...
So, there is only one cross-threads usage in the CreateImageFromRawDataInMainThreadSyncTask. I removed it at the above patch.
Assignee | ||
Comment 4•9 years ago
|
||
Reporter | ||
Updated•9 years ago
|
Attachment #8689410 -
Flags: review?(bzbarsky)
Reporter | ||
Comment 5•9 years ago
|
||
Comment on attachment 8689410 [details]
MozReview Request: Bug 1224647 - part1 - remove ErrorResult in the creating ImageBitmap from ImageData code path; r=bz
https://reviewboard.mozilla.org/r/25631/#review23063
::: dom/canvas/ImageBitmap.cpp:157
(Diff revision 1)
> + if (NS_WARN_IF(!image)) {
How can this be null? CairoImage doesn't have a custom operator new, and this is not using fallible new. AS far as I can tell, you can just leave this function as it was, except remove the ErrorResult argument.
::: dom/canvas/ImageBitmap.cpp:288
(Diff revision 1)
> + MOZ_ASSERT(!(*aImage), "Pass an existing Image into CreateImageFromRawDataInMainThreadSyncTask.");
You mean "Don't pass"?
::: dom/canvas/ImageBitmap.cpp:694
(Diff revision 1)
> + aRv = error; // Do not call Throw() because we might assign success codes.
No, this is not OK unless you know for a fact that the mainthread end of this never calls ThrowTypeError() or ThrowRangeError() or ThrowDOMException() or ThrowJSException() or NoteJSContextException() and never will. Trying to do this with any of those error codes will assert.
Assignee | ||
Comment 6•9 years ago
|
||
https://reviewboard.mozilla.org/r/25631/#review23063
> How can this be null? CairoImage doesn't have a custom operator new, and this is not using fallible new. AS far as I can tell, you can just leave this function as it was, except remove the ErrorResult argument.
Ya, there is no way for the *image* to be null and remove the ErrorResult argument is good. I will do it.
> You mean "Don't pass"?
Yes and sorry.
> No, this is not OK unless you know for a fact that the mainthread end of this never calls ThrowTypeError() or ThrowRangeError() or ThrowDOMException() or ThrowJSException() or NoteJSContextException() and never will. Trying to do this with any of those error codes will assert.
Understood. Luckily, in the main thread, only Throw() could be called on the ErrorResult object and the ErrorResult object is destructed after the error code was stolen. So, I think the code here is safe, maybe I can add a comment to describe the behavior here.
Or, I think it's better to remove the ErrorResult in the code path from CreateImageFromRawData() to CreateSurfaceFromRawData() and CreateImageFromSurface() so that we can keep this bad usage away.
What do u think?
Reporter | ||
Comment 7•9 years ago
|
||
> Luckily, in the main thread, only Throw() could be called on the ErrorResult object
Right now. My point is that this is fragile; someone could easily change the mainthread behavior without realizing how it affects the worker behavior.
> Or, I think it's better to remove the ErrorResult in the code path from
> CreateImageFromRawData() to CreateSurfaceFromRawData() and CreateImageFromSurface() so
> that we can keep this bad usage away.
If we can do that, that would be great. If the code always does a Throw(), it can just be converted to using an nsresult return value for now.
The other option would be to come up with an explicit way to move an ErrorResult across threads, perhaps based on the existing IPC code for moving one across processes. Not sure how much work that would be, and I'm definitely not asking you to sign up to do that.
Assignee | ||
Comment 8•9 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #7)
> > Or, I think it's better to remove the ErrorResult in the code path from
> > CreateImageFromRawData() to CreateSurfaceFromRawData() and CreateImageFromSurface() so
> > that we can keep this bad usage away.
>
> If we can do that, that would be great. If the code always does a Throw(),
> it can just be converted to using an nsresult return value for now.
I am going to take this approach in this bug. Since we only throw NS_ERROR_NOT_AVAILABLE, I will just check whether the return value is null or not without using a nsresult.
Should I open a new MozReview series? or keep appending on the current one?
Assignee | ||
Updated•9 years ago
|
Attachment #8689410 -
Attachment description: MozReview Request: Bug 1224647 - remove cross-threads usages of ErrorResult; r?bz → MozReview Request: Bug 1224647 - part1 - remove ErrorResult in the creating ImageBitmap from ImageData code path; r?bz
Attachment #8689410 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 9•9 years ago
|
||
Comment on attachment 8689410 [details]
MozReview Request: Bug 1224647 - part1 - remove ErrorResult in the creating ImageBitmap from ImageData code path; r=bz
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/25631/diff/1-2/
Assignee | ||
Comment 10•9 years ago
|
||
Bug 1224647 - part2 - remove ErrorResult in the creating ImageBitmap from Blob code path; r?bz
Attachment #8690678 -
Flags: review?(bzbarsky)
Reporter | ||
Comment 11•9 years ago
|
||
Comment on attachment 8689410 [details]
MozReview Request: Bug 1224647 - part1 - remove ErrorResult in the creating ImageBitmap from ImageData code path; r=bz
https://reviewboard.mozilla.org/r/25631/#review23529
r=me. Sorry for the lag responding to comment 8. :(
Attachment #8689410 -
Flags: review?(bzbarsky) → review+
Reporter | ||
Comment 12•9 years ago
|
||
Comment on attachment 8690678 [details]
MozReview Request: Bug 1224647 - part2 - remove ErrorResult in the creating ImageBitmap from Blob code path; r=bz
https://reviewboard.mozilla.org/r/25903/#review23531
r=me as long as those NS_ERROR_NOT_AVAILABLE can't happen in any cases per spec.
Attachment #8690678 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 13•9 years ago
|
||
Thanks for the review!
try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=7ea92459dd29
Assignee | ||
Comment 14•9 years ago
|
||
Comment on attachment 8689410 [details]
MozReview Request: Bug 1224647 - part1 - remove ErrorResult in the creating ImageBitmap from ImageData code path; r=bz
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/25631/diff/2-3/
Attachment #8689410 -
Attachment description: MozReview Request: Bug 1224647 - part1 - remove ErrorResult in the creating ImageBitmap from ImageData code path; r?bz → MozReview Request: Bug 1224647 - part1 - remove ErrorResult in the creating ImageBitmap from ImageData code path; r=bz
Assignee | ||
Comment 15•9 years ago
|
||
Comment on attachment 8690678 [details]
MozReview Request: Bug 1224647 - part2 - remove ErrorResult in the creating ImageBitmap from Blob code path; r=bz
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/25903/diff/1-2/
Attachment #8690678 -
Attachment description: MozReview Request: Bug 1224647 - part2 - remove ErrorResult in the creating ImageBitmap from Blob code path; r?bz → MozReview Request: Bug 1224647 - part2 - remove ErrorResult in the creating ImageBitmap from Blob code path; r=bz
Assignee | ||
Comment 16•9 years ago
|
||
Rebased and try again, which looks good.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f60d4f70f6e9&selectedJob=14108581
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 17•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/3751aad52208
https://hg.mozilla.org/integration/mozilla-inbound/rev/f628ddbbbbff
Keywords: checkin-needed
Comment 18•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/3751aad52208
https://hg.mozilla.org/mozilla-central/rev/f628ddbbbbff
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
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
•