diff --git a/internal/driver/glfw/loop.go b/internal/driver/glfw/loop.go index 34c5c2ecc4..82d5dc0cb5 100644 --- a/internal/driver/glfw/loop.go +++ b/internal/driver/glfw/loop.go @@ -99,7 +99,7 @@ func (d *gLDriver) drawSingleFrame() { } func (d *gLDriver) runGL() { - eventTick := time.NewTicker(time.Second / 60) + //eventTick := time.NewTicker(time.Second / 60) run.L.Lock() run.flag = true @@ -114,7 +114,7 @@ func (d *gLDriver) runGL() { for { select { case <-d.done: - eventTick.Stop() + //eventTick.Stop() d.drawDone <- nil // wait for draw thread to stop d.Terminate() fyne.CurrentApp().Lifecycle().(*app.Lifecycle).TriggerStopped() @@ -124,8 +124,9 @@ func (d *gLDriver) runGL() { if f.done != nil { f.done <- struct{}{} } - case <-eventTick.C: - d.tryPollEvents() + //case <-eventTick.C: + default: + d.tryWaitEventsTimeout(0.08333) newWindows := []fyne.Window{} reassign := false for _, win := range d.windowList() { diff --git a/internal/driver/glfw/loop_desktop.go b/internal/driver/glfw/loop_desktop.go index 652e6cf023..ae38d55b01 100644 --- a/internal/driver/glfw/loop_desktop.go +++ b/internal/driver/glfw/loop_desktop.go @@ -24,6 +24,16 @@ func (d *gLDriver) initGLFW() { }) } +func (d *gLDriver) tryWaitEventsTimeout(timeoutSeconds float64) { + defer func() { + if r := recover(); r != nil { + fyne.LogError(fmt.Sprint("GLFW waitEvents error: ", r), nil) + } + }() + + glfw.WaitEventsTimeout(timeoutSeconds) +} + func (d *gLDriver) tryPollEvents() { defer func() { if r := recover(); r != nil {