Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport running WebGL in its own thread or on the main thread. #23777
Conversation
|
@bors-servo try=wpt |
Support running WebGL in its own thread or on the main thread. This is the final missing piece to support WebGL in ANGLE on Windows. ANGLE doesn't support multiple GL contexts on separate threads using the same underlying Direct3d device, so we need to process all GL operations for WebGL on the same thread as the compositor. These changes try to retain enough flexibility to support both approaches so we can get WebGL working on Windows ASAP. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23697 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23777) <!-- Reviewable:end -->
|
One missing piece - I totally stubbed out the main-thread support for dom2texture in OutputHandler. |
|
|
c97999d
to
f069ede
|
@bors-servo try=wpt |
Support running WebGL in its own thread or on the main thread. This is the final missing piece to support WebGL in ANGLE on Windows. ANGLE doesn't support multiple GL contexts on separate threads using the same underlying Direct3d device, so we need to process all GL operations for WebGL on the same thread as the compositor. These changes try to retain enough flexibility to support both approaches so we can get WebGL working on Windows ASAP. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23697 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23777) <!-- Reviewable:end -->
|
|
|
With the off thread tests, lots of gl errors like:
With the main thread tests, lots of gl errors like:
|
|
@bors-servo try=wpt |
Support running WebGL in its own thread or on the main thread. This is the final missing piece to support WebGL in ANGLE on Windows. ANGLE doesn't support multiple GL contexts on separate threads using the same underlying Direct3d device, so we need to process all GL operations for WebGL on the same thread as the compositor. These changes try to retain enough flexibility to support both approaches so we can get WebGL working on Windows ASAP. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23697 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23777) <!-- Reviewable:end -->
|
|
|
@bors-servo try=wpt |
|
Would you like me to review this? |
|
Sigh, this is adding yet more complexity to the main event loop, but there's not much we can do about that. My main concern is the extra thread that's being spawned, that wakes the main event loop up for each GL command. That's a lot of context switching and message forwarding! Also, doesn't the WebGL thread keep track of the current GL context? Isn't it going to be rather surprised if the current GL context isn't the one it expects? |
| // Interpose a new channel in between the existing WebGL channel endpoints. | ||
| // This will bounce all WebGL messages through a second thread adding a small | ||
| // delay, but this will also ensure that the main thread will wake up and | ||
| // process the WebGL message when it arrives. |
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jul 25, 2019
Member
Oh that's annoying. It introduces yet another thread, which is context switched in for every GL command, plus it calls the event loop waker on every GL command. This seems quite expensive.
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jul 25, 2019
Member
Can we not move this logic into webgl, so the event loop waker is only used on commands like gl.finish()? (Similar to how the canvas is dirtied at the moment).
| @@ -71,6 +71,13 @@ where | |||
| WebGLReceiver::Mpsc(ref receiver) => receiver.recv().map_err(|_| ()), | |||
| } | |||
| } | |||
|
|
|||
| pub fn try_recv(&self) -> Result<T, ()> { | |||
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jul 25, 2019
Member
This version of try_recv doesn't distinguish between failure due to no message being present, and failure due to the channel being closed. Annoying, but possibly inevitable, unless there's some secret ipc-fu.
|
@asajeffrey Done! I tested all four permutations of ipc/main-thread and everything works. I need to rebase to pick up the clone->clone_box changes, but this is ready for review. |
|
Okay, this looks good. The only thing I think I'd do differently is make the event loop waker non-optional. At this point you can r=me. |
|
@bors-servo r=asajeffrey |
|
|
Support running WebGL in its own thread or on the main thread. This is the final missing piece to support WebGL in ANGLE on Windows. ANGLE doesn't support multiple GL contexts on separate threads using the same underlying Direct3d device, so we need to process all GL operations for WebGL on the same thread as the compositor. These changes try to retain enough flexibility to support both approaches so we can get WebGL working on Windows ASAP. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23697 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23777) <!-- Reviewable:end -->
|
|
|
|
@bors-servo retry |
Support running WebGL in its own thread or on the main thread. This is the final missing piece to support WebGL in ANGLE on Windows. ANGLE doesn't support multiple GL contexts on separate threads using the same underlying Direct3d device, so we need to process all GL operations for WebGL on the same thread as the compositor. These changes try to retain enough flexibility to support both approaches so we can get WebGL working on Windows ASAP. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #23697 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23777) <!-- Reviewable:end -->
|
|
jdm commentedJul 15, 2019
•
edited by SimonSapin
This is the final missing piece to support WebGL in ANGLE on Windows. ANGLE doesn't support multiple GL contexts on separate threads using the same underlying Direct3d device, so we need to process all GL operations for WebGL on the same thread as the compositor. These changes try to retain enough flexibility to support both approaches so we can get WebGL working on Windows ASAP.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is