detached 043cd76

fix(webkit): set strict memory threshold before conservative to avoid assertion

commit
043cd76f32a4522578fdd7c88ff689b9ca11a35c
author
brice · · 2025-12-28 17:13 UTC
committer
brice · · 2025-12-29 17:28 UTC
parent
3ef6fdf
signature
unsigned
1 file · +20 -4
M internal/infrastructure/webkit/memory_pressure.go +20 -4
@@ -26,6 +26,10 @@ func (*MemoryPressureApplier) ApplyNetworkProcessSettings(ctx context.Context, c
2626 return nil
2727 }
2828
29+ if cfg.ConservativeThreshold > 0 && cfg.StrictThreshold <= 0 {
30+ log.Warn().Msg("conservative threshold set without strict threshold; skipping conservative to avoid WebKit assertion")
31+ }
32+
2933 settings := buildMemoryPressureSettings(cfg)
3034 if settings == nil {
3135 return nil
@@ -54,6 +58,10 @@ func (*MemoryPressureApplier) ApplyWebProcessSettings(ctx context.Context, cfg *
5458 return nil, nil
5559 }
5660
61+ if cfg.ConservativeThreshold > 0 && cfg.StrictThreshold <= 0 {
62+ log.Warn().Msg("conservative threshold set without strict threshold; skipping conservative to avoid WebKit assertion")
63+ }
64+
5765 settings := buildMemoryPressureSettings(cfg)
5866 if settings == nil {
5967 return nil, nil
@@ -88,12 +96,20 @@ func buildMemoryPressureSettings(cfg *port.MemoryPressureConfig) *webkit.MemoryP
8896 }
8997
9098 // Thresholds must be in (0, 1)
91- if cfg.ConservativeThreshold > 0 && cfg.ConservativeThreshold < 1 {
92- settings.SetConservativeThreshold(cfg.ConservativeThreshold)
99+ // IMPORTANT: WebKit asserts that conservative < strict, so set strict first.
100+ strict := cfg.StrictThreshold
101+ conservative := cfg.ConservativeThreshold
102+
103+ if strict > 0 && strict < 1 {
104+ settings.SetStrictThreshold(strict)
93105 }
94106
95- if cfg.StrictThreshold > 0 && cfg.StrictThreshold < 1 {
96- settings.SetStrictThreshold(cfg.StrictThreshold)
107+ // Only set conservative when we also have a strict threshold; otherwise
108+ // WebKit's internal default strict value may not be initialized yet.
109+ if conservative > 0 && conservative < 1 && strict > 0 {
110+ if conservative < strict {
111+ settings.SetConservativeThreshold(conservative)
112+ }
97113 }
98114
99115 // Kill threshold: -1 = unset, 0 = never kill, >0 = threshold
@@ -26,6 +26,10 @@ func (*MemoryPressureApplier) ApplyNetworkProcessSettings(ctx context.Context, c
26 return nil26 return nil
27 }27 }
28 28
29+ if cfg.ConservativeThreshold > 0 && cfg.StrictThreshold <= 0 {
30+ log.Warn().Msg("conservative threshold set without strict threshold; skipping conservative to avoid WebKit assertion")
31+ }
32+
29 settings := buildMemoryPressureSettings(cfg)33 settings := buildMemoryPressureSettings(cfg)
30 if settings == nil {34 if settings == nil {
31 return nil35 return nil
@@ -54,6 +58,10 @@ func (*MemoryPressureApplier) ApplyWebProcessSettings(ctx context.Context, cfg *
54 return nil, nil58 return nil, nil
55 }59 }
56 60
61+ if cfg.ConservativeThreshold > 0 && cfg.StrictThreshold <= 0 {
62+ log.Warn().Msg("conservative threshold set without strict threshold; skipping conservative to avoid WebKit assertion")
63+ }
64+
57 settings := buildMemoryPressureSettings(cfg)65 settings := buildMemoryPressureSettings(cfg)
58 if settings == nil {66 if settings == nil {
59 return nil, nil67 return nil, nil
@@ -88,12 +96,20 @@ func buildMemoryPressureSettings(cfg *port.MemoryPressureConfig) *webkit.MemoryP
88 }96 }
89 97
90 // Thresholds must be in (0, 1)98 // Thresholds must be in (0, 1)
91- if cfg.ConservativeThreshold > 0 && cfg.ConservativeThreshold < 1 {99+ // IMPORTANT: WebKit asserts that conservative < strict, so set strict first.
92- settings.SetConservativeThreshold(cfg.ConservativeThreshold)100+ strict := cfg.StrictThreshold
101+ conservative := cfg.ConservativeThreshold
102+
103+ if strict > 0 && strict < 1 {
104+ settings.SetStrictThreshold(strict)
93 }105 }
94 106
95- if cfg.StrictThreshold > 0 && cfg.StrictThreshold < 1 {107+ // Only set conservative when we also have a strict threshold; otherwise
96- settings.SetStrictThreshold(cfg.StrictThreshold)108+ // WebKit's internal default strict value may not be initialized yet.
109+ if conservative > 0 && conservative < 1 && strict > 0 {
110+ if conservative < strict {
111+ settings.SetConservativeThreshold(conservative)
112+ }
97 }113 }
98 114
99 // Kill threshold: -1 = unset, 0 = never kill, >0 = threshold115 // Kill threshold: -1 = unset, 0 = never kill, >0 = threshold

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