gui: the masking demo shows no video where WebKitGTK can't play one (avk458 on X)
On Omarchy (Arch + Hyprland) without gst-plugins-good, opening Masking's
"How masking works" aborted WebKitWebProcess about 3s later: WebKitGTK
2.52.6 gives every <video>, muted ones too, an autoaudiosink, which lives
in libgstautodetect.so ("no such element factory autoaudiosink", then a
SIGABRT). The window was left frozen on its last frame ("一点就崩溃再点
magpie就卡死了").
Cause: b90e81da1's noVideo was only in GET /api/settings. The page's
state.settings comes from /api/state, which never carried it, so a demo
opened before Settings was visited set the webm src. The GUI fixture put
noVideo into /api/state's settings and hid it.
Now boot.js says noVideo (app only, not a browser tab) before the page
paints, and demo.js reads window.bootPrefs.noVideo; the poster shows
instead. Also, for BoyC338's memory question: folded, or with the page
left, the video lets go of its source (removeAttribute src + load), so
no decoder or buffer is held; opened again it goes on from where it was.
Run:
- mote: GUI masking-demo, masking-records, i18n-keys in Chromium and
WebKit: 116 pass, 0 fail.
- mote: go test -run 'TestBootSaysNoVideo|TestBoot|TestSettings|
TestFontSettingsAPIAndBoot|Budget' ./internal/gui ok; gofmt -l none;
vet for darwin, GOOS=windows, GOOS=linux -tags nogui ok.
- WSL magpie-desktop: go test -tags gtk3 -run 'TestBootSaysNoVideo|
TestGstAutodetect|TestWebkitDefaults|TestSettings' ./internal/gui ok.
- Real app on omarchy, v0.1.1840 release: Masking > demo row aborted
WebKitWebProcess (coredump 07:10:10 UTC), window frozen. Built this
tree with make release-linux in WSL and ran it there: demo opens with
the poster and animates, fold/reopen, Agents and back to Masking all
respond; no coredump, no autoaudiosink line, both web processes alive.
These ran at base ea53eb126; rebased onto 05ed578bd (redact/gateway
changes, none in internal/gui) and the budgets run again before push.
Broken by hand:
- demo.js reading state.settings?.noVideo: the poster test is red in
both engines.
- hold() commented out: the folded test is red in WebKit.
- boot flag removed: TestBootSaysNoVideo is red.
Not tried: a Linux system with gst-plugins-good (the video path there
is unchanged); arm64 Linux. Recovering a window whose web process died
(web-process-terminated) is not handled by magpie or Wails; not in this
commit.
This commit is contained in:
+8
-4
@@ -403,9 +403,6 @@ type settingsJSON struct {
|
||||
GatewayOn bool `json:"gatewayOn,omitempty"`
|
||||
GatewayWhy string `json:"gatewayWhy,omitempty"`
|
||||
Web bool `json:"web,omitempty"`
|
||||
// NoVideo: this app's webview would crash on a <video> (Linux without
|
||||
// gst-plugins-good, webkitPlaysVideo), so the pages show no video
|
||||
NoVideo bool `json:"noVideo,omitempty"`
|
||||
// the proxy vendor requests go through now, and where it came from:
|
||||
// settings, environment, system, off or none
|
||||
ProxyNow string `json:"proxyNow"`
|
||||
@@ -630,7 +627,6 @@ func settingsState() settingsJSON {
|
||||
}
|
||||
s.WSL = runtime.GOOS == "windows"
|
||||
s.Web = webPage.Load()
|
||||
s.NoVideo = !s.Web && !webkitPlaysVideo()
|
||||
s.GatewayOn, s.GatewayWhy = gatewayMode(s.Web)
|
||||
s.LANKey = "" // the retained credential belongs on disk, not in UI state
|
||||
// the GitHub token, masked, and where the library's requests take one
|
||||
@@ -859,6 +855,14 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
if !isWeb(w) {
|
||||
boot["uiFont"], boot["codeFont"] = s.UIFont, s.CodeFont
|
||||
}
|
||||
// and whether this app's webview would crash on a <video> (Linux
|
||||
// without gst-plugins-good, webkitPlaysVideo), so the pages show
|
||||
// none. Here, not in the settings: the page's settings come from
|
||||
// /api/state, which never said it, so the masking demo set its
|
||||
// video and the web process aborted (avk458 on X, omarchy)
|
||||
if !isWeb(w) && !webkitPlaysVideo() {
|
||||
boot["noVideo"] = true
|
||||
}
|
||||
// and whether it is a gateway's page alone (gatewaymode.go), so the
|
||||
// pages left out never show
|
||||
if on, _ := gatewayMode(ownWeb(w)); on {
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
// sheets, the notebook and the boxes are the page's, moved over her. The
|
||||
// video is fetched when the row is first opened, never before. It plays
|
||||
// while the row is open and on screen, once through, and rests on its last
|
||||
// step; with reduced motion it starts there. Where the app's webview would
|
||||
// crash on a video (state.settings.noVideo), she is her poster.
|
||||
// step; with reduced motion it starts there. Folded, or with the page left,
|
||||
// the video lets its source go, so a folded demo holds no decoder or
|
||||
// buffered video. Where the app's webview would crash on a video
|
||||
// (bootPrefs.noVideo: Linux without gst-plugins-good), she is her poster.
|
||||
|
||||
const XQD_END = 27.5;
|
||||
const XQD_STEPS = [
|
||||
@@ -364,18 +366,31 @@ function maskDemoBuild(body) {
|
||||
// video plays T leans toward its time, so she and the sheets keep step.
|
||||
// Without the video (it can't load or play) the frame clock alone runs.
|
||||
const vid = stage.querySelector("video");
|
||||
let T = 0, playing = !calm(), open = false, seen = false, raf = 0, last = 0, fixed = 0, theme = "";
|
||||
let T = 0, playing = !calm(), open = false, seen = false, raf = 0, last = 0, fixed = 0, theme = "", take = "";
|
||||
const dark = matchMedia("(prefers-color-scheme: dark)");
|
||||
// boot.js says it before the page draws: /api/state's settings don't
|
||||
// carry it, so a demo opened before Settings was never told (avk458 on X)
|
||||
const noVideo = !!window.bootPrefs?.noVideo;
|
||||
const pickVid = () => {
|
||||
const th = document.documentElement.dataset.theme || (dark.matches ? "dark" : "light");
|
||||
if (th === theme) return;
|
||||
theme = th;
|
||||
vid.poster = `plugins/redact/xq_${th}.jpg`;
|
||||
if (!state.settings?.noVideo) vid.src = `plugins/redact/xq_${th}.webm`;
|
||||
take = noVideo ? "" : `plugins/redact/xq_${th}.webm`;
|
||||
// a new source starts paused: it goes on where the old one was
|
||||
seek(T);
|
||||
wake();
|
||||
};
|
||||
// the take is the video's source only while the row is open on the page
|
||||
// shown; let go, the video frees its decoder and what it buffered
|
||||
const hold = () => {
|
||||
if (take && open && vp.getClientRects().length) {
|
||||
if (vid.getAttribute("src") !== take) vid.src = take;
|
||||
} else if (vid.hasAttribute("src")) {
|
||||
vid.removeAttribute("src");
|
||||
vid.load();
|
||||
}
|
||||
};
|
||||
const seek = (t0) => { T = t0; if (vid.readyState >= 1) vid.currentTime = Math.min(t0, vid.duration - .02); };
|
||||
vid.addEventListener("loadedmetadata", () => seek(T));
|
||||
let lastScrub = -1;
|
||||
@@ -417,6 +432,7 @@ function maskDemoBuild(body) {
|
||||
// wake starts or stops it as the row, the page and the window say
|
||||
function wake() {
|
||||
open = $("#mdRow")?.getAttribute("aria-expanded") === "true";
|
||||
hold();
|
||||
if (live() && playing) {
|
||||
seek(T);
|
||||
vid.play().catch(() => {});
|
||||
@@ -440,6 +456,6 @@ function maskDemoBuild(body) {
|
||||
if (!playing) seek(25.6);
|
||||
render(T); sync();
|
||||
setPlaying(playing);
|
||||
root.__state = () => ({ T, ct: vid.currentTime, paused: vid.paused, rs: vid.readyState, src: vid.currentSrc.split("/").pop(), playing, raf: !!raf });
|
||||
root.__state = () => ({ T, ct: vid.currentTime, paused: vid.paused, rs: vid.readyState, src: vid.getAttribute("src") ? vid.currentSrc.split("/").pop() : "", playing, raf: !!raf });
|
||||
return { wake, root };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Where the app's webview would crash on a <video> (Linux without
|
||||
// gst-plugins-good), boot.js says so before the page draws, and the
|
||||
// state the page loads first doesn't need to: the masking demo read it from
|
||||
// /api/state's settings, which never carried it, set its video and the web
|
||||
// process aborted on omarchy (avk458 on X). A browser tab plays video in
|
||||
// the user's own browser and is never told.
|
||||
func TestBootSaysNoVideo(t *testing.T) {
|
||||
builtinHome(t)
|
||||
prev := webkitPlaysVideo
|
||||
t.Cleanup(func() { webkitPlaysVideo = prev })
|
||||
boot := func(h http.Handler) string {
|
||||
rec := httptest.NewRecorder()
|
||||
h.ServeHTTP(rec, httptest.NewRequest("GET", "/boot.js", nil))
|
||||
return rec.Body.String()
|
||||
}
|
||||
webkitPlaysVideo = func() bool { return false }
|
||||
if b := boot(Handler(nil, nil)); !strings.Contains(b, `"noVideo":true`) {
|
||||
t.Fatalf("the app, with no video: %s", b)
|
||||
}
|
||||
if b := boot(Handler(webHost{}, nil)); strings.Contains(b, "noVideo") {
|
||||
t.Fatalf("a browser tab plays its own video: %s", b)
|
||||
}
|
||||
webkitPlaysVideo = func() bool { return true }
|
||||
if b := boot(Handler(nil, nil)); strings.Contains(b, "noVideo") {
|
||||
t.Fatalf("the app, with video: %s", b)
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,12 @@ const K = "1792987654321000001";
|
||||
const record = { key: K, t: new Date(Date.now() - 60e3).toISOString(), route: "messages", what: "chat", agent: "claude", provider: "anthropic", model: "claude-opus-4-1", n: 1,
|
||||
values: [{ p: "{{PERSON_bbbb2222}}", k: "PERSON", b: "model", h: "", l: 3, n: 1 }], snips: { "{{PERSON_bbbb2222}}": "ask {{PERSON_bbbb2222}} about it" } };
|
||||
|
||||
function serve(lang, theme, fetched, more) {
|
||||
function serve(lang, theme, fetched, more, boot = {}) {
|
||||
const settings = { theme, lang, tray: "panel", currency: "usd", redact: true, redactPersonal: true, ...more };
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"${theme}",web:true};` });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme, web: true, ...boot })};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [{ id: "claude", name: "Claude Code", icon: "claudecode-color", fields: [] }], profiles: [], settings });
|
||||
if (url.pathname === "/api/settings") return json(settings);
|
||||
@@ -56,7 +56,7 @@ async function open(engine, lang, width, opts = {}) {
|
||||
page.setDefaultTimeout(8000);
|
||||
const errors = [], fetched = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, opts.theme || "light", fetched, opts.settings));
|
||||
await page.route("**/*", serve(lang, opts.theme || "light", fetched, opts.settings, opts.boot));
|
||||
await page.goto("http://magpie.test/?view=masking");
|
||||
await page.locator("#mdRow").waitFor();
|
||||
return { browser, page, errors, fetched };
|
||||
@@ -227,9 +227,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
// on Linux without gst-plugins-good WebKitGTK's web process aborts on any
|
||||
// video (stock Omarchy), so there she is her poster and the sheets still move
|
||||
// video (stock Omarchy), so there she is her poster and the sheets still
|
||||
// move. The app says so in boot.js, as the server does; /api/state's
|
||||
// settings never carry it (avk458 on X: the demo crashed omarchy's app)
|
||||
test(`${engine}: where the app can't play video she is her poster, and the demo still plays`, async (t) => {
|
||||
const { browser, page, errors, fetched } = await open(engine, "en", 1100, { motion: true, settings: { noVideo: true } });
|
||||
const { browser, page, errors, fetched } = await open(engine, "en", 1100, { motion: true, boot: { noVideo: true } });
|
||||
t.after(() => browser.close());
|
||||
await page.locator("#mdRow").click();
|
||||
await until(async () => (await state(page)).T > 1, 8000, page);
|
||||
@@ -241,6 +243,27 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await until(async () => (await state(page)).T > a.T + .5, 8000, page);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
// folded, or with the page left, the video lets go of its source, so it
|
||||
// holds no decoder or buffered video; opened again it goes on where it was
|
||||
test(`${engine}: folded or left, the demo holds no video; opened again it goes on`, async (t) => {
|
||||
const { browser, page, errors } = await open(engine, "en", 1100, { motion: true });
|
||||
t.after(() => browser.close());
|
||||
const src = () => page.evaluate(() => document.querySelector(".xqd video").getAttribute("src"));
|
||||
await page.locator("#mdRow").click();
|
||||
await until(async () => { const s = await state(page); return !s.paused && s.ct > 1; }, 8000, page);
|
||||
await page.locator("#mdRow").click();
|
||||
await until(async () => (await src()) === null, 8000, page);
|
||||
const folded = await state(page);
|
||||
assert.equal(folded.rs, 0, "no data held while folded");
|
||||
await page.locator("#mdRow").click();
|
||||
await until(async () => { const s = await state(page); return s.src === "xq_light.webm" && !s.paused && s.ct > folded.T; }, 8000, page);
|
||||
// another page: the masking view hidden
|
||||
await page.evaluate(() => { document.querySelector("#view-masking").hidden = true; });
|
||||
await until(async () => (await src()) === null, 8000, page);
|
||||
await page.evaluate(() => { document.querySelector("#view-masking").hidden = false; });
|
||||
await until(async () => (await src()) !== null, 8000, page);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
// her background is the card's: the video's own corners, against the card
|
||||
|
||||
@@ -6,4 +6,4 @@ package gui
|
||||
func webkitDefaults() {}
|
||||
|
||||
// webkitPlaysVideo: the other systems' webviews play video.
|
||||
func webkitPlaysVideo() bool { return true }
|
||||
var webkitPlaysVideo = func() bool { return true }
|
||||
|
||||
Reference in New Issue
Block a user