Closed Bug 1503236 Opened 7 years ago Closed 7 years ago

Move WorkletImpl reference from WorkletGlobalScope to classes inheriting WorkletGlobalScope

Categories

(Core :: Web Audio, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla65
Tracking Status
firefox65 --- fixed

People

(Reporter: abienner, Assigned: abienner)

References

Details

Attachments

(1 file)

No description provided.
This would need bug 1503228 to be landed first.
Depends on: 1503228
Summarizing a discussion I had with Karl: I believe having WorkletImpl being a member of the inherited classes instead of the WorkletGlobalScope class is better, because otherwise accessing any method/member specific to a given worklet (e.g. audio related things in AudioWorkletGlobalScope, for which it doesn't make sense to have methods in WorkletGlobalScope) would require a static_cast. This has undefined behavior if we would cast to the wrong type. Thus this has little chance to happen because we have few places where we could mis-initialized the WorkletImpl member, with this patch we will be sure this can never happen at all. To make the WorkletImpl object accessible from WorkletGlobalScope, Impl() is now pure virtual. Karl noted this could be an issue if we need to call Impl() at constructor/destruction, but this is not needed currently. If someone accidentally do so, we believe this will probably lead to a crash so be noticeable right away. And clang has warning to spot this case. I wrote a patch for clang to control it with a -W flag, to have the possibility to turn it into an error, something we should probably do on our codebase once it is landed and we have updated our clang version. https://reviews.llvm.org/D53807
Summary: Move WorkletImpl from WorkletWorkletScope to inherited WorkletScope classes → Move WorkletImpl from WorkletGlobalScope to classes inheriting WorkletGlobalScope
Blocks: 1501709
Attachment #9021139 - Attachment description: Bug 1503236 - Move WorkletImpl from WorkletGlobalScope to classes inheriting WorkletGlobalScope. r=karlt → Move WorkletImpl reference from WorkletGlobalScope to classes inheriting WorkletGlobalScope
Just recording that I didn't see a problem with the static_cast because the code would provide that the cast is to the correct type. If that approach turns out to be more practical, then we can switch back to that. I don't expect the virtual calls to be particularly frequent and so I'm not aware of any significant problems with this change in approach (unless the method is required from the destructor).
Summary: Move WorkletImpl from WorkletGlobalScope to classes inheriting WorkletGlobalScope → Move WorkletImpl reference from WorkletGlobalScope to classes inheriting WorkletGlobalScope
Rank: 15
Priority: -- → P2
Keywords: checkin-needed
Pushed by nbeleuzu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/10d4bab0bccb Move WorkletImpl reference from WorkletGlobalScope to classes inheriting WorkletGlobalScope r=karlt
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: