detached 30e77be

fix: log recovered panic in safeGLibType instead of silencing it

commit
30e77be245bccd60e9a1458167a9ce7e7fb053f6
author
brice · · 2026-03-06 06:03 UTC
parent
9803305
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +7 -3
M internal/infrastructure/webkit/webview.go +7 -3
@@ -1092,12 +1092,12 @@ const (
10921092 )
10931093
10941094 func detectPermissionRequestKind(ctx context.Context, requestPtr uintptr) permissionRequestKind {
1095- if gtype, ok := safeGLibType(webkit.UserMediaPermissionRequestGLibType); ok {
1095+ if gtype, ok := safeGLibType(ctx, webkit.UserMediaPermissionRequestGLibType); ok {
10961096 if isPermissionRequestType(ctx, requestPtr, gtype) {
10971097 return permissionRequestKindUserMedia
10981098 }
10991099 }
1100- if gtype, ok := safeGLibType(webkit.DeviceInfoPermissionRequestGLibType); ok {
1100+ if gtype, ok := safeGLibType(ctx, webkit.DeviceInfoPermissionRequestGLibType); ok {
11011101 if isPermissionRequestType(ctx, requestPtr, gtype) {
11021102 return permissionRequestKindDeviceInfo
11031103 }
@@ -1108,9 +1108,13 @@ func detectPermissionRequestKind(ctx context.Context, requestPtr uintptr) permis
11081108 // safeGLibType calls a GType accessor function, recovering from panics caused
11091109 // by unregistered (nil) puregotk function pointers. Returns the GType and true
11101110 // on success, or zero and false if the call panicked.
1111-func safeGLibType(fn func() gtypes.GType) (gtype gtypes.GType, ok bool) {
1111+func safeGLibType(ctx context.Context, fn func() gtypes.GType) (gtype gtypes.GType, ok bool) {
11121112 defer func() {
11131113 if r := recover(); r != nil {
1114+ logging.FromContext(ctx).Warn().
1115+ Str("component", "permission").
1116+ Interface("panic", r).
1117+ Msg("GType accessor panicked (unregistered puregotk binding?)")
11141118 gtype = 0
11151119 ok = false
11161120 }
@@ -1092,12 +1092,12 @@ const (
1092 )1092 )
1093 1093
1094 func detectPermissionRequestKind(ctx context.Context, requestPtr uintptr) permissionRequestKind {1094 func detectPermissionRequestKind(ctx context.Context, requestPtr uintptr) permissionRequestKind {
1095- if gtype, ok := safeGLibType(webkit.UserMediaPermissionRequestGLibType); ok {1095+ if gtype, ok := safeGLibType(ctx, webkit.UserMediaPermissionRequestGLibType); ok {
1096 if isPermissionRequestType(ctx, requestPtr, gtype) {1096 if isPermissionRequestType(ctx, requestPtr, gtype) {
1097 return permissionRequestKindUserMedia1097 return permissionRequestKindUserMedia
1098 }1098 }
1099 }1099 }
1100- if gtype, ok := safeGLibType(webkit.DeviceInfoPermissionRequestGLibType); ok {1100+ if gtype, ok := safeGLibType(ctx, webkit.DeviceInfoPermissionRequestGLibType); ok {
1101 if isPermissionRequestType(ctx, requestPtr, gtype) {1101 if isPermissionRequestType(ctx, requestPtr, gtype) {
1102 return permissionRequestKindDeviceInfo1102 return permissionRequestKindDeviceInfo
1103 }1103 }
@@ -1108,9 +1108,13 @@ func detectPermissionRequestKind(ctx context.Context, requestPtr uintptr) permis
1108 // safeGLibType calls a GType accessor function, recovering from panics caused1108 // safeGLibType calls a GType accessor function, recovering from panics caused
1109 // by unregistered (nil) puregotk function pointers. Returns the GType and true1109 // by unregistered (nil) puregotk function pointers. Returns the GType and true
1110 // on success, or zero and false if the call panicked.1110 // on success, or zero and false if the call panicked.
1111-func safeGLibType(fn func() gtypes.GType) (gtype gtypes.GType, ok bool) {1111+func safeGLibType(ctx context.Context, fn func() gtypes.GType) (gtype gtypes.GType, ok bool) {
1112 defer func() {1112 defer func() {
1113 if r := recover(); r != nil {1113 if r := recover(); r != nil {
1114+ logging.FromContext(ctx).Warn().
1115+ Str("component", "permission").
1116+ Interface("panic", r).
1117+ Msg("GType accessor panicked (unregistered puregotk binding?)")
1114 gtype = 01118 gtype = 0
1115 ok = false1119 ok = false
1116 }1120 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close