Performance Optimizations
Relevant source files
The following files were used as context for generating this wiki page:
GeekEZ Browser incorporates several performance optimizations designed to enhance startup speed, reduce memory consumption, and manage disk space efficiently. These improvements ensure a smoother user experience, especially when running multiple profiles simultaneously. The optimizations focus on the browser launch process, resource management through caching strategies, and the efficient startup of core components like the Xray-core proxy engine.
The core of these optimizations lies in the strategic use of Chromium launch arguments, a streamlined startup sequence, and an automated cleanup process. According to the project's documentation, these changes have resulted in a 40% faster startup time and a 30% reduction in RAM usage.
Sources: README.md, CHANGELOG_v1.2.3.md, renderer.js:284
Browser Launch Optimizations
The primary method for performance enhancement is the use of specific command-line arguments when launching the Puppeteer-controlled Chromium instance. These arguments are configured to reduce resource usage and bypass non-essential startup procedures.
Sources: main.js:520-543, CHANGELOG_v1.2.3.md
Launch Arguments
The following table details the performance-related arguments passed to the browser instance upon launch.
| Argument | Description |
|---|---|
--no-first-run | Skips the first-run wizard, accelerating the initial launch. |
--no-default-browser-check | Disables the check to see if the browser is the default one on the system. |
--disable-background-timer-throttling | Prevents Chromium from throttling timers in background tabs, ensuring consistent performance. |
--disable-backgrounding-occluded-windows | Prevents the browser from lowering the priority of windows that are not visible. |
--disable-renderer-backgrounding | Prevents the browser from lowering the priority of background renderers. |
--disable-dev-shm-usage | Reduces the usage of shared memory, which can be beneficial in resource-constrained environments. |
--disk-cache-size=52428800 | Limits the disk cache size to 50MB, preventing excessive disk space usage. |
--media-cache-size=52428800 | Limits the media cache size to 50MB. |
Sources: main.js:537-543, CHANGELOG_v1.2.3.md
The implementation of these arguments can be found in the launch-profile IPC handler:
// main.js:536-543
// 性能优化参数
'--no-first-run', // 跳过首次运行向导
'--no-default-browser-check', // 跳过默认浏览器检查
'--disable-background-timer-throttling', // 防止后台标签页被限速
'--disable-backgrounding-occluded-windows',
'--disable-renderer-backgrounding',
'--disable-dev-shm-usage', // 减少共享内存使用
'--disk-cache-size=52428800', // 限制磁盘缓存为 50MB
'--media-cache-size=52428800' // 限制媒体缓存为 50MB
Sources: main.js:536-543
Resource Management
GeekEZ Browser implements both proactive and reactive resource management strategies to control memory and disk usage.
Cache Size Limiting
As shown in the launch arguments, the browser's disk and media caches are explicitly limited to 50MB each. This prevents the browser profiles from consuming large amounts of disk space over time, which is crucial when managing dozens or hundreds of profiles.
Sources: main.js:542-543
Automatic Cache Cleanup
A cleanup process is automatically triggered when a browser instance is closed. This process empties the cache directories within the profile's user data folder, ensuring that temporary files do not accumulate and that each session starts with a clean slate, further saving disk space.
This is handled by the disconnected event listener on the browser object.
// main.js:560-573
browser.on('disconnected', async () => {
if (activeProcesses[profileId]) {
// ... process cleanup logic ...
// 性能优化:清理缓存文件,节省磁盘空间
try {
const cacheDir = path.join(userDataDir, 'Default', 'Cache');
const codeCacheDir = path.join(userDataDir, 'Default', 'Code Cache');
if (fs.existsSync(cacheDir)) await fs.emptyDir(cacheDir);
if (fs.existsSync(codeCacheDir)) await fs.emptyDir(codeCacheDir);
} catch (e) {
// 忽略清理错误
}
if (!sender.isDestroyed()) sender.send('profile-status', { id: profileId, status: 'stopped' });
}
});
Sources: main.js:560-573, CHANGELOG_v1.2.3.md
Startup Process Optimization
The overall application startup flow has been optimized to reduce delays and launch browser profiles more quickly.
Optimized Profile Launch Flow
The following diagram illustrates the sequence of events when a user launches a profile, highlighting the key optimization steps.
This diagram shows the optimized flow for launching a profile, including the reduced wait time for Xray.
Sources: main.js:421-582, renderer.js:564-568
Reduced Xray-core Wait Time
When a profile is launched, the application starts an Xray-core process to handle proxying. The wait time after spawning this process has been reduced from 1000ms to 300ms. This change significantly contributes to the 40% improvement in startup speed, as the browser launch does not have to wait as long for the proxy to initialize.
// main.js:509-510
// 优化:减少等待时间,Xray 通常 300ms 内就能启动
await new Promise(resolve => setTimeout(resolve, 300));
Sources: main.js:509-510, CHANGELOG_v1.2.3.md
Initial Setup Performance
Performance considerations are also present in the application's initial setup script. The setup.js script is responsible for downloading necessary dependencies like Xray-core and the correct version of Chromium.
To accelerate this process for users in regions with restricted network access, the script first checks for global network connectivity. If a connection to Google is not successful, it automatically uses a mirror (gh-proxy.com for Xray and npmmirror.com for Chrome) to download the dependencies, ensuring a faster and more reliable setup experience.
This diagram shows how setup.js uses mirrors to optimize dependency downloads.
Sources: setup.js:77-90, 151-163
Summary
The performance optimizations in GeekEZ Browser are a combination of fine-tuned launch configurations, intelligent resource management, and a streamlined startup sequence. By limiting cache sizes, cleaning up temporary files automatically, reducing artificial delays, and using optimized dependency download methods, the application provides a fast and efficient experience. These enhancements are critical for the browser's intended use case of managing multiple, isolated e-commerce accounts, where performance directly impacts user productivity.
Sources: README.md, CHANGELOG_v1.2.3.md, main.js