diff options
-rw-r--r-- | components/canvas/webgl_thread.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index f2099094127..faea8e76d1c 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -112,12 +112,14 @@ impl WebGLMainThread { // Any context could be current when we start. self.thread_data.borrow_mut().bound_context_id = None; - self.shut_down.set( - !self - .thread_data - .borrow_mut() - .process(EventLoop::Nonblocking), - ); + let result = self + .thread_data + .borrow_mut() + .process(EventLoop::Nonblocking); + if !result { + self.shut_down.set(true); + WEBGL_MAIN_THREAD.with(|thread_data| thread_data.borrow_mut().take()); + } } /// Returns the main GL thread if called from the main thread, |