blockingly shut-down webrender when exiting webgl_thread

This commit is contained in:
Gregory Terzian 2020-06-15 21:02:36 +08:00
parent 581ade575e
commit 59896748b5
40 changed files with 47 additions and 49 deletions

View file

@ -333,6 +333,14 @@ impl WebGLThread {
Ok(msg) => {
let exit = self.handle_msg(msg, &webgl_chan);
if exit {
// Call remove_context functions in order to correctly delete WebRender image keys.
let context_ids: Vec<WebGLContextId> = self.contexts.keys().map(|id| *id).collect();
for id in context_ids {
self.remove_webgl_context(id);
}
// Block on shutting-down WebRender.
self.webrender_api.shut_down(true);
return;
}
}
@ -1101,16 +1109,6 @@ impl WebGLThread {
}
}
impl Drop for WebGLThread {
fn drop(&mut self) {
// Call remove_context functions in order to correctly delete WebRender image keys.
let context_ids: Vec<WebGLContextId> = self.contexts.keys().map(|id| *id).collect();
for id in context_ids {
self.remove_webgl_context(id);
}
}
}
/// Helper struct to store cached WebGLContext information.
struct WebGLContextInfo {
/// Currently used WebRender image key.