Fix a rare crash when running simulate on macOS.

The bug was introduced in 2f0fb1e4ef. The glfwSwapBuffers call should occur on the main UI thread, not the CoreVideo DisplayLink thread.

PiperOrigin-RevId: 517172202
Change-Id: I2491f2194765019748198cd0cc61ca9263331b01
This commit is contained in:
Saran Tunyasuvunakool
2023-03-16 11:05:38 -07:00
committed by Copybara-Service
parent 230e2780de
commit 81ba9ec54a
3 changed files with 11 additions and 21 deletions
+2 -6
View File
@@ -175,14 +175,10 @@ bool GlfwAdapter::ShouldCloseWindow() const {
void GlfwAdapter::SwapBuffers() {
#ifdef __APPLE__
if (core_video_.has_value()) {
core_video_->EnqueueSwap();
core_video_->WaitForSwap();
} else {
Glfw().glfwSwapBuffers(window_);
core_video_->WaitForDisplayRefresh();
}
#else
Glfw().glfwSwapBuffers(window_);
#endif
Glfw().glfwSwapBuffers(window_);
}
void GlfwAdapter::ToggleFullscreen() {