Documentation
¶
Overview ¶
Package window watches the page of Djinn's native window from outside it, on Linux. When the web process that draws the page ends (after an Intel GPU hang, out of memory, or killed; W353, W366), it is logged with WebKit's state (the page's load events, the web processes' CPU and memory) and the kernel's GPU hangs, told outside the window, and rescued step by step, once each: the page loads again, then the window opens again with a new view. The new view draws in software rendering only after a GPU hang, until Djinn restarts: rendering stays on the GPU at every start (decision Q89).
Index ¶
Constants ¶
const Lookback = 10 * time.Minute
Lookback is how long before djinn up started the kernel's log is read: the hang that kills a web process may come just before a start (17/10: 30 s before an install restarted Djinn).
const MaxHangs = 12
MaxHangs is how many hangs a Watch keeps, the latest: a driver that hangs in a loop fills the kernel's log.
const Sample = 500 * time.Millisecond
Sample is how long the web processes' CPU is measured, when a page's web process ends.
Variables ¶
var Journal = func(ctx context.Context, since time.Time) ([]byte, error) { if runtime.GOOS != "linux" { return nil, nil } ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() return exec.CommandContext(ctx, "journalctl", "-k", "-q", "--no-pager", "-o", "short-iso", "--since", "@"+strconv.FormatInt(since.Unix(), 10)).Output() }
Journal is the kernel's log of this boot since a time, as journalctl -o short-iso prints it; nothing outside Linux. Tests replace it.
var ProcRoot = "/proc"
ProcRoot is where the processes are read: /proc. Tests replace it.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// Ended is the reason the page's web process ended ("crashed", "memory", "terminated").
Ended string
// Hangs are the GPU hangs and resets of the kernel's log since Lookback before djinn up started.
Hangs []Hang
// Did is what the Watch did.
Did Rescue
// Software tells that the new view draws in software rendering, after a GPU hang, until Djinn restarts.
Software bool
// Err is why the page could not load again, or the window open again.
Err error
}
Event is what a Watch tells outside the window.
type Hang ¶
type Hang struct {
// Time is when the kernel logged it; zero when the line names none.
Time time.Time
// Line is the line, without its time and host.
Line string
}
Hang is a line of the kernel's log that tells a GPU hang or reset.
type Process ¶
type Process struct {
PID int
// Name is the kernel's, cut at 15 characters: WebKitWebProces, WebKitNetworkPr.
Name string
// State is the kernel's letter: R running, S sleeping, D waiting on a disk, Z a zombie.
State string
// RSS is the memory it holds, in bytes.
RSS uint64
// CPU is the CPU time it took since it started.
CPU time.Duration
}
Process is a process of WebKit, as the log of a dead page names it.
func WebKitProcesses ¶
WebKitProcesses is the processes of WebKit parent started: its web and network processes.
type Watch ¶
type Watch struct {
// Started is when djinn up started: the kernel's log is read from Lookback before it, the load events are timed
// from it.
Started time.Time
// Hangs reads the GPU hangs and resets of the kernel's log since a time: KernelHangs when nil. Tests replace it.
Hangs func(ctx context.Context, since time.Time) ([]Hang, error)
// Processes reads the web processes of the window: djinn up's children whose name starts with WebKit, when nil.
// Tests replace it.
Processes func() []Process
// Sample is how long the web processes' CPU is measured: Sample when zero, none when negative.
Sample time.Duration
// Reload loads the page again in its view. Nil: no reload.
Reload func() error
// Recreate opens the window again with a new view, in software rendering when software, in place of the dead one.
// Nil: no new view.
Recreate func(software bool) error
// Tell says what happened outside the window: a line where djinn up runs, a desktop notification. Nil says nothing.
Tell func(Event)
// contains filtered or unexported fields
}
Watch follows the windows of one djinn up: Opened as each opens, Loaded at each of its page's load events, Ended as its web process ends. It reloads a page once and recreates a window once, per djinn up, never in a loop.
func (*Watch) Ended ¶
Ended tells that the web process of the current page ended, for reason, at its start or any time after: the page is dead.