Reduce Android and iOS background work

This commit is contained in:
shen
2026-12-03 16:46:29 -08:00
parent 9e05f1ad93
commit e68cb6c909
12 changed files with 189 additions and 60 deletions
+22 -8
View File
@@ -89,14 +89,24 @@ type Engine struct {
func (e *Engine) Snapshot() Snapshot {
e.mu.Lock()
defer e.mu.Unlock()
state := e.state
if state == "" {
state = "Stopped"
return Snapshot{State: e.stateLocked(), Version: "1.14.3", RuntimeEvents: e.runtimeLogs.snapshot()}
}
func (e *Engine) State() string {
e.mu.Lock()
defer e.mu.Unlock()
return e.stateLocked()
}
func (e *Engine) stateLocked() string {
switch {
case e.state == "":
return "Stopped"
case e.state == "Running" && e.ctx.Err() != nil:
return "Failed"
default:
return e.state
}
if state == "Running" && e.ctx.Err() != nil {
state = "Failed"
}
return Snapshot{State: state, Version: "1.14.3", RuntimeEvents: e.runtimeLogs.snapshot()}
}
func (e *Engine) Start(parent context.Context, config Config) error {
@@ -155,7 +165,11 @@ func (e *Engine) Start(parent context.Context, config Config) error {
// Collect bounded, credential-redacted warning/error events in memory.
// Raw upstream logs must never go to stderr or a user's log file.
if !e.selfTestTrace {
options.Log = &option.LogOptions{Level: "info", Output: os.DevNull}
level := "info"
if runtime.GOOS == "android" {
level = "warn"
}
options.Log = &option.LogOptions{Level: level, Output: os.DevNull}
}
instance, err := box.New(box.Options{Options: options, Context: ctx})
if err != nil {