engine.go RawHistoryFolder
1package config
2
3// EngineConfig holds engine selection and universal engine options.
4type EngineConfig struct {
5 Type string `mapstructure:"type" toml:"type" yaml:"type"`
6 PoolPrewarmCount int `mapstructure:"pool_prewarm_count" toml:"pool_prewarm_count" yaml:"pool_prewarm_count"`
7 ZoomCacheSize int `mapstructure:"zoom_cache_size" toml:"zoom_cache_size" yaml:"zoom_cache_size"`
8 Profile PerformanceProfile `mapstructure:"profile" toml:"profile" yaml:"profile"`
9 CookiePolicy CookiePolicy `mapstructure:"cookie_policy" toml:"cookie_policy" yaml:"cookie_policy"`
10 WebKit WebKitEngineConfig `mapstructure:"webkit" toml:"webkit" yaml:"webkit"`
11}
12
13// WebKitEngineConfig holds WebKit-specific engine options.
14type WebKitEngineConfig struct {
15 // Skia rendering threads
16 SkiaCPUPaintingThreads int `mapstructure:"skia_cpu_painting_threads" toml:"skia_cpu_painting_threads" yaml:"skia_cpu_painting_threads"`
17 SkiaGPUPaintingThreads int `mapstructure:"skia_gpu_painting_threads" toml:"skia_gpu_painting_threads" yaml:"skia_gpu_painting_threads"`
18 SkiaEnableCPURendering bool `mapstructure:"skia_enable_cpu_rendering" toml:"skia_enable_cpu_rendering" yaml:"skia_enable_cpu_rendering"`
19
20 // WebKit compositor
21 DisableDMABufRenderer bool `mapstructure:"disable_dmabuf_renderer" toml:"disable_dmabuf_renderer" yaml:"disable_dmabuf_renderer"`
22 ForceCompositingMode bool `mapstructure:"force_compositing_mode" toml:"force_compositing_mode" yaml:"force_compositing_mode"`
23 DisableCompositingMode bool `mapstructure:"disable_compositing_mode" toml:"disable_compositing_mode" yaml:"disable_compositing_mode"`
24
25 // GTK/GSK
26 GSKRenderer GSKRendererMode `mapstructure:"gsk_renderer" toml:"gsk_renderer" yaml:"gsk_renderer"`
27 DisableMipmaps bool `mapstructure:"disable_mipmaps" toml:"disable_mipmaps" yaml:"disable_mipmaps"`
28 PreferGL bool `mapstructure:"prefer_gl" toml:"prefer_gl" yaml:"prefer_gl"`
29
30 // Debug
31 ShowFPS bool `mapstructure:"show_fps" toml:"show_fps" yaml:"show_fps"`
32 SampleMemory bool `mapstructure:"sample_memory" toml:"sample_memory" yaml:"sample_memory"`
33 DebugFrames bool `mapstructure:"debug_frames" toml:"debug_frames" yaml:"debug_frames"`
34 DrawCompositingIndicators bool `mapstructure:"draw_compositing_indicators" toml:"draw_compositing_indicators" yaml:"draw_compositing_indicators"` //nolint:lll // struct tags exceed lll limit
35
36 // Privacy (WebKit-specific)
37 ITPEnabled bool `mapstructure:"itp_enabled" toml:"itp_enabled" yaml:"itp_enabled"`
38
39 // GStreamer
40 ForceVSync bool `mapstructure:"force_vsync" toml:"force_vsync" yaml:"force_vsync"`
41 GLRenderingMode GLRenderingMode `mapstructure:"gl_rendering_mode" toml:"gl_rendering_mode" yaml:"gl_rendering_mode"`
42 GStreamerDebugLevel int `mapstructure:"gstreamer_debug_level" toml:"gstreamer_debug_level" yaml:"gstreamer_debug_level"`
43
44 // Runtime prefix for WebKitGTK libraries
45 Prefix string `mapstructure:"prefix" toml:"prefix" yaml:"prefix"`
46
47 // Web process memory pressure
48 WebProcessMemoryLimitMB int `mapstructure:"web_process_memory_limit_mb" toml:"web_process_memory_limit_mb" yaml:"web_process_memory_limit_mb"` //nolint:lll // struct tags exceed lll limit
49 WebProcessMemoryPollIntervalSec float64 `mapstructure:"web_process_memory_poll_interval_sec" toml:"web_process_memory_poll_interval_sec" yaml:"web_process_memory_poll_interval_sec"` //nolint:lll // struct tags exceed lll limit
50 WebProcessMemoryConservativeThreshold float64 `mapstructure:"web_process_memory_conservative_threshold" toml:"web_process_memory_conservative_threshold" yaml:"web_process_memory_conservative_threshold"` //nolint:lll // struct tags exceed lll limit
51 WebProcessMemoryStrictThreshold float64 `mapstructure:"web_process_memory_strict_threshold" toml:"web_process_memory_strict_threshold" yaml:"web_process_memory_strict_threshold"` //nolint:lll // struct tags exceed lll limit
52
53 // Network process memory pressure
54 NetworkProcessMemoryLimitMB int `mapstructure:"network_process_memory_limit_mb" toml:"network_process_memory_limit_mb" yaml:"network_process_memory_limit_mb"` //nolint:lll // struct tags exceed lll limit
55 NetworkProcessMemoryPollIntervalSec float64 `mapstructure:"network_process_memory_poll_interval_sec" toml:"network_process_memory_poll_interval_sec" yaml:"network_process_memory_poll_interval_sec"` //nolint:lll // struct tags exceed lll limit
56 NetworkProcessMemoryConservativeThreshold float64 `mapstructure:"network_process_memory_conservative_threshold" toml:"network_process_memory_conservative_threshold" yaml:"network_process_memory_conservative_threshold"` //nolint:lll // struct tags exceed lll limit
57 NetworkProcessMemoryStrictThreshold float64 `mapstructure:"network_process_memory_strict_threshold" toml:"network_process_memory_strict_threshold" yaml:"network_process_memory_strict_threshold"` //nolint:lll // struct tags exceed lll limit
58}
59
60// PerformanceConfigFromEngine constructs a PerformanceConfig from the
61// new [engine] config section, for use with ResolvePerformanceProfile.
62func PerformanceConfigFromEngine(e *EngineConfig) PerformanceConfig {
63 if e == nil {
64 return PerformanceConfig{}
65 }
66 return PerformanceConfig{
67 Profile: e.Profile,
68 ZoomCacheSize: e.ZoomCacheSize,
69 WebViewPoolPrewarmCount: e.PoolPrewarmCount,
70 SkiaCPUPaintingThreads: e.WebKit.SkiaCPUPaintingThreads,
71 SkiaGPUPaintingThreads: e.WebKit.SkiaGPUPaintingThreads,
72 SkiaEnableCPURendering: e.WebKit.SkiaEnableCPURendering,
73 WebProcessMemoryLimitMB: e.WebKit.WebProcessMemoryLimitMB,
74 WebProcessMemoryPollIntervalSec: e.WebKit.WebProcessMemoryPollIntervalSec,
75 WebProcessMemoryConservativeThreshold: e.WebKit.WebProcessMemoryConservativeThreshold,
76 WebProcessMemoryStrictThreshold: e.WebKit.WebProcessMemoryStrictThreshold,
77 NetworkProcessMemoryLimitMB: e.WebKit.NetworkProcessMemoryLimitMB,
78 NetworkProcessMemoryPollIntervalSec: e.WebKit.NetworkProcessMemoryPollIntervalSec,
79 NetworkProcessMemoryConservativeThreshold: e.WebKit.NetworkProcessMemoryConservativeThreshold,
80 NetworkProcessMemoryStrictThreshold: e.WebKit.NetworkProcessMemoryStrictThreshold,
81 }
82}