Skip to content

Commit

Permalink
Update go-gl/glfw to v3.3.10 and remove workaround
Browse files Browse the repository at this point in the history
This is a great GLFW update (see go-gl/glfw#396) because it not only fixes various bugs but one of the bugs that it fixes addresses a bug that we have been working around for a long time.

The workaround for this issue involved defering a recover() to catch the panic that could occur for incorrectly invalid keycodes. This did not only degrade performance due to having to run recover but the defer was also making it impossible to inline the method. Given that we are running this in the (rather hot) runloop, I expect the perofrmance improvement to be quite substancial.
  • Loading branch information
Jacalz committed Mar 6, 2024
1 parent 45cca22 commit beed274
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/fyne-io/glfw-js v0.0.0-20240101223322-6e1efdc71b7a
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20231223183121-56fa3ac82ce7
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb
github.com/go-ole/go-ole v1.2.6
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8
github.com/go-text/typesetting v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20231223183121-56fa3ac82ce7 h1:7tf/0aw5DxRQjr7WaNqgtjidub6v21L2cogKIbMcTYw=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20231223183121-56fa3ac82ce7/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb h1:S9I8pIVT5JHKDvmI1vQ0qs5fqxzUfhcZm/YbUC/8k1k=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8 h1:VkKnvzbvHqgEfm351rfr8Uclu5fnwq8HP2ximUzJsBM=
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/glfw/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (d *gLDriver) runGL() {
f.f()
f.done <- struct{}{}
case <-eventTick.C:
d.tryPollEvents()
d.pollEvents()
windowsToRemove := 0
for _, win := range d.windowList() {
w := win.(*window)
Expand Down
11 changes: 1 addition & 10 deletions internal/driver/glfw/loop_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
package glfw

import (
"fmt"

"fyne.io/fyne/v2"

"github.com/go-gl/glfw/v3.3/glfw"
Expand All @@ -23,14 +21,7 @@ func (d *gLDriver) initGLFW() {
})
}

func (d *gLDriver) tryPollEvents() {
defer func() {
// See https://github.com/glfw/glfw/issues/1785 and https://github.com/fyne-io/fyne/issues/1024.
if r := recover(); r != nil {
fyne.LogError(fmt.Sprint("GLFW poll event error: ", r), nil)
}
}()

func (d *gLDriver) pollEvents() {
glfw.PollEvents() // This call blocks while window is being resized, which prevents freeDirtyTextures from being called
}

Expand Down
11 changes: 1 addition & 10 deletions internal/driver/glfw/loop_goxjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
package glfw

import (
"fmt"

"fyne.io/fyne/v2"

gl "github.com/fyne-io/gl-js"
Expand All @@ -23,14 +21,7 @@ func (d *gLDriver) initGLFW() {
})
}

func (d *gLDriver) tryPollEvents() {
defer func() {
// See https://github.com/glfw/glfw/issues/1785 and https://github.com/fyne-io/fyne/issues/1024.
if r := recover(); r != nil {
fyne.LogError(fmt.Sprint("GLFW poll event error: ", r), nil)
}
}()

func (d *gLDriver) pollEvents() {
glfw.PollEvents() // This call blocks while window is being resized, which prevents freeDirtyTextures from being called
}

Expand Down

0 comments on commit beed274

Please sign in to comment.