window

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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).

View Source
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.

View Source
const Sample = 500 * time.Millisecond

Sample is how long the web processes' CPU is measured, when a page's web process ends.

Variables

View Source
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.

View Source
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.

func Hangs

func Hangs(log []byte) []Hang

Hangs is the GPU hangs and resets of a kernel log, the last MaxHangs.

func KernelHangs

func KernelHangs(ctx context.Context, since time.Time) ([]Hang, error)

KernelHangs is the GPU hangs and resets of the kernel's log since a time, the last MaxHangs.

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

func WebKitProcesses(parent int) []Process

WebKitProcesses is the processes of WebKit parent started: its web and network processes.

func (Process) Describe

func (p Process) Describe(before []Process, sample time.Duration) string

Describe names p for the log: its PID, name, state, memory, CPU time, and its CPU over sample when before holds it: "pid 4242 WebKitWebProces S rss 155 MB cpu 1.2 s, 0 % over 500ms".

type Rescue

type Rescue int

Rescue is what a Watch did about a dead page.

const (
	// Nothing: the page loaded again and the window opened again already, or neither can be done.
	Nothing Rescue = iota
	// Reloaded: the page loads again, in the same view.
	Reloaded
	// Recreated: the window opens again, with a new view and a new web process.
	Recreated
)

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

func (w *Watch) Ended(reason string)

Ended tells that the web process of the current page ended, for reason, at its start or any time after: the page is dead.

func (*Watch) Loaded

func (w *Watch) Loaded(event string)

Loaded logs a load event of the current window's page ("started", "committed", "finished", "failed: …"), and keeps it for the log of a dead page.

func (*Watch) Opened

func (w *Watch) Opened()

Opened tells that a window opened, its page the current one from now on.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL