Firefox gets longer to start (a Snap's first start after boot is slow)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
This commit is contained in:
王性驊 2026-11-08 01:05:31 +08:00
parent ebaedecbae
commit cc41ca8ccb
1 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,8 @@ use std::time::{Duration, Instant};
pub const PORT: u16 = 9333;
/// How long to wait for the browser to come up (estimated).
const START_TIMEOUT_SECS: u64 = 20;
/// Firefox from a Snap can take much longer the first time after the computer starts (estimated).
const FIREFOX_START_TIMEOUT_SECS: u64 = 60;
/// The first profile: the browser folder made before profiles existed (its logins stay).
pub const DEFAULT_PROFILE: &str = "預設";
/// The person's own browser (read through accessibility, like Grok Bot's Computer Use helper):
@ -703,7 +705,7 @@ fn ensure_firefox(profile: &str, dir: &std::path::Path, first_url: Option<&str>)
}
c.spawn().map_err(|e| format!("打不開 Firefox:{e}"))?;
let start = Instant::now();
while start.elapsed() < Duration::from_secs(START_TIMEOUT_SECS) {
while start.elapsed() < Duration::from_secs(FIREFOX_START_TIMEOUT_SECS) {
if let Some(p) = firefox_port(dir) {
return Ok(("Firefox", p, true));
}