feat: add load-failed signal logging for content blocker debugging
Connect WebKit's load-failed signal to log when page loads fail, including content blocker rejections. Error message details are limited to the failing URI until bnema/puregotk#6 is resolved (GError* exposed as raw uintptr in signal callbacks).
- commit
- 29bdfb1e2911cbaa6d74c74fa3ef877e091a8bfa
- author
- brice · · 2026-03-27 06:30 UTC
- parent
- 483aebe
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +16 -0
M internal/infrastructure/webkit/webview.go +16 -0
| @@ -418,6 +418,7 @@ func (wv *WebView) connectSignals() { | |||
| 418 | 418 | wv.connectURISignal() | |
| 419 | 419 | wv.connectFaviconSignal() | |
| 420 | 420 | wv.connectProgressSignal() | |
| 421 | + | wv.connectLoadFailedSignal() | |
| 421 | 422 | wv.connectDecidePolicySignal() | |
| 422 | 423 | wv.connectEnterFullscreenSignal() | |
| 423 | 424 | wv.connectLeaveFullscreenSignal() | |
| @@ -464,6 +465,21 @@ func (wv *WebView) connectLoadChangedSignal() { | |||
| 464 | 465 | wv.signalIDs = append(wv.signalIDs, uintptr(sigID)) | |
| 465 | 466 | } | |
| 466 | 467 | ||
| 468 | + | func (wv *WebView) connectLoadFailedSignal() { | |
| 469 | + | loadFailedCb := func(_ webkit.WebView, event webkit.LoadEvent, failingURI string, _ uintptr) bool { | |
| 470 | + | // Note: error details are a raw uintptr (GError*) — see bnema/puregotk#6 | |
| 471 | + | // for tracking proper *glib.Error conversion in signal callbacks. | |
| 472 | + | wv.logger.Warn(). | |
| 473 | + | Str("component", "webview"). | |
| 474 | + | Str("uri", failingURI). | |
| 475 | + | Int("load_event", int(event)). | |
| 476 | + | Msg("load failed") | |
| 477 | + | return false | |
| 478 | + | } | |
| 479 | + | sigID := wv.inner.ConnectLoadFailed(&loadFailedCb) | |
| 480 | + | wv.signalIDs = append(wv.signalIDs, uintptr(sigID)) | |
| 481 | + | } | |
| 482 | + | ||
| 467 | 483 | func (wv *WebView) connectCloseSignal() { | |
| 468 | 484 | closeCb := func(_ webkit.WebView) { | |
| 469 | 485 | if wv.OnClose != nil { | |
| @@ -418,6 +418,7 @@ func (wv *WebView) connectSignals() { | |||||
| 418 | wv.connectURISignal() | 418 | wv.connectURISignal() | ||
| 419 | wv.connectFaviconSignal() | 419 | wv.connectFaviconSignal() | ||
| 420 | wv.connectProgressSignal() | 420 | wv.connectProgressSignal() | ||
| 421 | + | wv.connectLoadFailedSignal() | |||
| 421 | wv.connectDecidePolicySignal() | 422 | wv.connectDecidePolicySignal() | ||
| 422 | wv.connectEnterFullscreenSignal() | 423 | wv.connectEnterFullscreenSignal() | ||
| 423 | wv.connectLeaveFullscreenSignal() | 424 | wv.connectLeaveFullscreenSignal() | ||
| @@ -464,6 +465,21 @@ func (wv *WebView) connectLoadChangedSignal() { | |||||
| 464 | wv.signalIDs = append(wv.signalIDs, uintptr(sigID)) | 465 | wv.signalIDs = append(wv.signalIDs, uintptr(sigID)) | ||
| 465 | } | 466 | } | ||
| 466 | 467 | ||||
| 468 | + | func (wv *WebView) connectLoadFailedSignal() { | |||
| 469 | + | loadFailedCb := func(_ webkit.WebView, event webkit.LoadEvent, failingURI string, _ uintptr) bool { | |||
| 470 | + | // Note: error details are a raw uintptr (GError*) — see bnema/puregotk#6 | |||
| 471 | + | // for tracking proper *glib.Error conversion in signal callbacks. | |||
| 472 | + | wv.logger.Warn(). | |||
| 473 | + | Str("component", "webview"). | |||
| 474 | + | Str("uri", failingURI). | |||
| 475 | + | Int("load_event", int(event)). | |||
| 476 | + | Msg("load failed") | |||
| 477 | + | return false | |||
| 478 | + | } | |||
| 479 | + | sigID := wv.inner.ConnectLoadFailed(&loadFailedCb) | |||
| 480 | + | wv.signalIDs = append(wv.signalIDs, uintptr(sigID)) | |||
| 481 | + | } | |||
| 482 | + | ||||
| 467 | func (wv *WebView) connectCloseSignal() { | 483 | func (wv *WebView) connectCloseSignal() { | ||
| 468 | closeCb := func(_ webkit.WebView) { | 484 | closeCb := func(_ webkit.WebView) { | ||
| 469 | if wv.OnClose != nil { | 485 | if wv.OnClose != nil { | ||