From 23f55f2ff88201b40aabd9c20c44de7075d9d665 Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Fri, 20 Oct 2023 15:54:50 +0300 Subject: [PATCH] Revert --- pkg/worker/caged/libretro/graphics/sdl.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/worker/caged/libretro/graphics/sdl.go b/pkg/worker/caged/libretro/graphics/sdl.go index 1d9271eb1..5473b84f3 100644 --- a/pkg/worker/caged/libretro/graphics/sdl.go +++ b/pkg/worker/caged/libretro/graphics/sdl.go @@ -5,6 +5,7 @@ import ( "unsafe" "github.com/giongto35/cloud-game/v3/pkg/logger" + "github.com/giongto35/cloud-game/v3/pkg/worker/thread" "github.com/veandco/go-sdl2/sdl" ) @@ -60,7 +61,7 @@ func NewSDLContext(cfg Config, log *logger.Logger) (*SDL, error) { var err error // In OSX 10.14+ window creation and context creation must happen in the main thread - display.w, display.glWCtx, err = createWindow() + thread.Main(func() { display.w, display.glWCtx, err = createWindow() }) if err != nil { return nil, fmt.Errorf("window fail: %w", err) } @@ -80,9 +81,11 @@ func NewSDLContext(cfg Config, log *logger.Logger) (*SDL, error) { func (s *SDL) Deinit() error { s.log.Debug().Msg("[SDL/OpenGL] shutdown...") destroyFramebuffer() - + var err error // In OSX 10.14+ window deletion must happen in the main thread - err := s.destroyWindow() + thread.Main(func() { + err = s.destroyWindow() + }) if err != nil { return fmt.Errorf("[SDL/OpenGL] deinit fail: %w", err) }