chore(logging): trace async webview prewarm
Add debug logs around pool background color setup and async prewarm scheduling/completion for easier startup diagnostics.
- commit
- aaa4919e62d25bfddb0d78f9d3e1da6dfe386723
- author
- brice · · 2025-12-27 08:33 UTC
- parent
- 0c81a22
- signature
- unsigned
2 files · +22 -4
M internal/infrastructure/webkit/pool.go +9 -1
| @@ -212,12 +212,19 @@ func (p *WebViewPool) Prewarm(ctx context.Context, count int) { | |||
| 212 | 212 | // This avoids blocking startup (especially cold-start navigation) while still | |
| 213 | 213 | // warming up WebViews for subsequent tab creation. | |
| 214 | 214 | func (p *WebViewPool) PrewarmAsync(ctx context.Context, count int) { | |
| 215 | + | log := logging.FromContext(ctx) | |
| 216 | + | ||
| 215 | 217 | if count <= 0 { | |
| 216 | 218 | count = p.config.PrewarmCount | |
| 217 | 219 | } | |
| 218 | - | if count <= 0 || p.closed.Load() { | |
| 220 | + | if count <= 0 { | |
| 219 | 221 | return | |
| 220 | 222 | } | |
| 223 | + | if p.closed.Load() { | |
| 224 | + | return | |
| 225 | + | } | |
| 226 | + | ||
| 227 | + | log.Debug().Int("count", count).Int("pool_size", len(p.pool)).Msg("scheduling async webview pool prewarm") | |
| 221 | 228 | ||
| 222 | 229 | p.wg.Add(1) | |
| 223 | 230 | var doneOnce sync.Once | |
| @@ -254,6 +261,7 @@ func (p *WebViewPool) PrewarmAsync(ctx context.Context, count int) { | |||
| 254 | 261 | ||
| 255 | 262 | remaining-- | |
| 256 | 263 | if remaining <= 0 { | |
| 264 | + | log.Debug().Int("pool_size", len(p.pool)).Msg("async webview pool prewarm complete") | |
| 257 | 265 | doneOnce.Do(p.wg.Done) | |
| 258 | 266 | return false | |
| 259 | 267 | } | |
| @@ -212,12 +212,19 @@ func (p *WebViewPool) Prewarm(ctx context.Context, count int) { | |||||
| 212 | // This avoids blocking startup (especially cold-start navigation) while still | 212 | // This avoids blocking startup (especially cold-start navigation) while still | ||
| 213 | // warming up WebViews for subsequent tab creation. | 213 | // warming up WebViews for subsequent tab creation. | ||
| 214 | func (p *WebViewPool) PrewarmAsync(ctx context.Context, count int) { | 214 | func (p *WebViewPool) PrewarmAsync(ctx context.Context, count int) { | ||
| 215 | + | log := logging.FromContext(ctx) | |||
| 216 | + | ||||
| 215 | if count <= 0 { | 217 | if count <= 0 { | ||
| 216 | count = p.config.PrewarmCount | 218 | count = p.config.PrewarmCount | ||
| 217 | } | 219 | } | ||
| 218 | - | if count <= 0 || p.closed.Load() { | 220 | + | if count <= 0 { |
| 219 | return | 221 | return | ||
| 220 | } | 222 | } | ||
| 223 | + | if p.closed.Load() { | |||
| 224 | + | return | |||
| 225 | + | } | |||
| 226 | + | ||||
| 227 | + | log.Debug().Int("count", count).Int("pool_size", len(p.pool)).Msg("scheduling async webview pool prewarm") | |||
| 221 | 228 | ||||
| 222 | p.wg.Add(1) | 229 | p.wg.Add(1) | ||
| 223 | var doneOnce sync.Once | 230 | var doneOnce sync.Once | ||
| @@ -254,6 +261,7 @@ func (p *WebViewPool) PrewarmAsync(ctx context.Context, count int) { | |||||
| 254 | 261 | ||||
| 255 | remaining-- | 262 | remaining-- | ||
| 256 | if remaining <= 0 { | 263 | if remaining <= 0 { | ||
| 264 | + | log.Debug().Int("pool_size", len(p.pool)).Msg("async webview pool prewarm complete") | |||
| 257 | doneOnce.Do(p.wg.Done) | 265 | doneOnce.Do(p.wg.Done) | ||
| 258 | return false | 266 | return false | ||
| 259 | } | 267 | } | ||
M internal/ui/app.go +13 -3
| @@ -228,12 +228,22 @@ func (a *App) applyGTKColorSchemePreference(ctx context.Context) { | |||
| 228 | 228 | } | |
| 229 | 229 | ||
| 230 | 230 | func (a *App) setupPoolBackgroundColor(ctx context.Context) { | |
| 231 | + | log := logging.FromContext(ctx) | |
| 232 | + | ||
| 231 | 233 | // Set theme background color on pool to eliminate white flash. | |
| 232 | 234 | // Must be done before any WebView creation so WebViews get the correct color. | |
| 233 | - | if a.pool != nil && a.deps != nil && a.deps.Theme != nil { | |
| 234 | - | r, g, b, alpha := a.deps.Theme.GetBackgroundRGBA() | |
| 235 | - | a.pool.SetBackgroundColor(r, g, b, alpha) | |
| 235 | + | if a.pool == nil { | |
| 236 | + | log.Debug().Msg("webview pool not available; skipping background color setup") | |
| 237 | + | return | |
| 236 | 238 | } | |
| 239 | + | if a.deps == nil || a.deps.Theme == nil { | |
| 240 | + | log.Debug().Msg("theme not available; skipping webview pool background color setup") | |
| 241 | + | return | |
| 242 | + | } | |
| 243 | + | ||
| 244 | + | r, g, b, alpha := a.deps.Theme.GetBackgroundRGBA() | |
| 245 | + | a.pool.SetBackgroundColor(r, g, b, alpha) | |
| 246 | + | log.Debug().Msg("configured webview pool background color") | |
| 237 | 247 | } | |
| 238 | 248 | ||
| 239 | 249 | func (a *App) prewarmWebViewPoolAsync(ctx context.Context) { | |
| @@ -228,12 +228,22 @@ func (a *App) applyGTKColorSchemePreference(ctx context.Context) { | |||||
| 228 | } | 228 | } | ||
| 229 | 229 | ||||
| 230 | func (a *App) setupPoolBackgroundColor(ctx context.Context) { | 230 | func (a *App) setupPoolBackgroundColor(ctx context.Context) { | ||
| 231 | + | log := logging.FromContext(ctx) | |||
| 232 | + | ||||
| 231 | // Set theme background color on pool to eliminate white flash. | 233 | // Set theme background color on pool to eliminate white flash. | ||
| 232 | // Must be done before any WebView creation so WebViews get the correct color. | 234 | // Must be done before any WebView creation so WebViews get the correct color. | ||
| 233 | - | if a.pool != nil && a.deps != nil && a.deps.Theme != nil { | 235 | + | if a.pool == nil { |
| 234 | - | r, g, b, alpha := a.deps.Theme.GetBackgroundRGBA() | 236 | + | log.Debug().Msg("webview pool not available; skipping background color setup") |
| 235 | - | a.pool.SetBackgroundColor(r, g, b, alpha) | 237 | + | return |
| 236 | } | 238 | } | ||
| 239 | + | if a.deps == nil || a.deps.Theme == nil { | |||
| 240 | + | log.Debug().Msg("theme not available; skipping webview pool background color setup") | |||
| 241 | + | return | |||
| 242 | + | } | |||
| 243 | + | ||||
| 244 | + | r, g, b, alpha := a.deps.Theme.GetBackgroundRGBA() | |||
| 245 | + | a.pool.SetBackgroundColor(r, g, b, alpha) | |||
| 246 | + | log.Debug().Msg("configured webview pool background color") | |||
| 237 | } | 247 | } | ||
| 238 | 248 | ||||
| 239 | func (a *App) prewarmWebViewPoolAsync(ctx context.Context) { | 249 | func (a *App) prewarmWebViewPoolAsync(ctx context.Context) { | ||