-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
script: Break the ScriptThread dependency on the initial Pipeline
#40918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ) -> JoinHandle<()> { | ||
| let webview_id = WebViewId::installed(); | ||
| let event_loop_id = ScriptEventLoopId::installed() | ||
| .expect("A DedicatedWorker should always be run from a ScriptThread context"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the case where a worker is launched from another worker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expect message is a bit confusing, so I'll update it. Essentially, the thread should either be a ScriptThread or a dedicated worker launched from another ScriptThread in which case the ScriptEventLoopId should also be installed. That said, maybe the ScriptEventLoopId should also be installed.
| .expect("Thread spawning failed") | ||
| } | ||
|
|
||
| pub(crate) fn webview_id(&self) -> Option<WebViewId> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use an Option here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this doesn't need to be an Option at all. I'll address it.
1e16e54 to
12653a0
Compare
12653a0 to
5687592
Compare
`ScriptThread`s start with an initial `Pipeline`, but that `Pipeline` should not be used for any `ScriptThread` global data as a `ScriptThread` can have any number of `Pipeline`s that come and go. There's no architectural reason why a `ScriptThread` should be associated with only a single `WebView`. This change makes it so that the `ScriptThread` no longer uses the `PipelineId` and the `WebViewId` of the initial `Pipeline` to initialize itself. Instead a `ScriptEventLoopId` is used to uniquely identify every `ScriptThread` in both the `ScriptThread` and the `Constellation`. The remaining use was for crash reporting. Now when a crash happens, it launches the sad tab in all `WebView`s that depeneded on that `ScriptThread`. This is a change which should allow simplifying the way that `EventLoop`s/`ScriptThread`s are started in the `Constellation`, which will be handled in a followup. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
5687592 to
13bbcd3
Compare
ScriptThreads start with an initialPipeline, but thatPipelineshould not be used for any
ScriptThreadglobal data as aScriptThreadcan have any number ofPipelines that come and go.There's no architectural reason why a
ScriptThreadshould beassociated with only a single
WebView.This change makes it so that the
ScriptThreadno longer uses thePipelineIdand theWebViewIdof the initialPipelineto initializeitself. Instead a
ScriptEventLoopIdis used to uniquely identify everyScriptThreadin both theScriptThreadand theConstellation.The remaining use was for crash reporting. Now when a crash happens, it
launches the sad tab in all
WebViews that depeneded on thatScriptThread.This is a change which should allow simplifying the way that
EventLoops/ScriptThreads are started in theConstellation, whichwill be handled in a followup.
Testing: This shouldn't change behavior except in the case where a
ScriptThreadis used in more than a singleWebView, which should workproperly now. I tested this change manually by running servoshell in
multiprocess mode while causing a panic to happen due to a null pointer
dereference. The sad tab appeared after this change, so things seem to work
properly still. Testing crashes is tricky with the way we test servo now.