Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: overlay text check waits for the seek's paint before measuring a backdrop (#11583)

[._.]/ Adam Eivy61387b7f855f
diff --git a/server/services/musicVideo/documentRender.js b/server/services/musicVideo/documentRender.js
index 2ca406a915..ed7d680ba7 100644
--- a/server/services/musicVideo/documentRender.js
+++ b/server/services/musicVideo/documentRender.js
@@ -567,6 +567,15 @@ export async function encodeDocumentComposition({
const PROBE_SCREENSHOT = Object.freeze({ format: 'png', optimizeForSpeed: true, fromSurface: true, captureBeyondViewport: false });
// Backdrop luminance is measured on a half-size frame (plenty for a contrast percentile).
const PROBE_BACKDROP_SCALE = 0.5;
+// Two animation frames after the seek and the text-hiding style: the first
+// commits what seek() painted, the second runs once that frame was produced, so
+// the backdrop screenshot cannot catch the page as it was before the seek (a
+// caption on a plate would read as pale on the bare page). Bounded for a page
+// that schedules no frames.
+const PROBE_PAINTED = `new Promise((resolve) => {
+ const timer = setTimeout(() => resolve(false), 1000);
+ requestAnimationFrame(() => requestAnimationFrame(() => { clearTimeout(timer); resolve(true); }));
+})`;
/**
* Open a project's composition document the way a render does (same staged
@@ -632,6 +641,8 @@ export async function probeDocumentText({ project, jobId, signal, sampleTimes, o
const records = await page.evaluate('globalThis.__portosTextProbe.end()');
let backdrop = null;
if (Array.isArray(records) && records.length) {
+ await page.evaluate(PROBE_PAINTED);
+ page.check();
const { data: png } = await page.send('Page.captureScreenshot', PROBE_SCREENSHOT);
const width = Math.max(1, Math.round(target.width * PROBE_BACKDROP_SCALE));
const { data: rgb, info } = await sharp(Buffer.from(png, 'base64')).removeAlpha().resize({ width }).raw().toBuffer({ resolveWithObject: true });
diff --git a/server/services/musicVideo/overlayTextService.browser.test.js b/server/services/musicVideo/overlayTextService.browser.test.js
index aa555f66c2..30fa7c06e2 100644
--- a/server/services/musicVideo/overlayTextService.browser.test.js
+++ b/server/services/musicVideo/overlayTextService.browser.test.js
@@ -94,7 +94,8 @@ describe.skipIf(!chrome)('overlay text check (headless Chrome)', () => {
expect(kinds('tiny tag')).toContain('small');
expect(kinds('DOM CAPTION')).toEqual(['contrast']);
expect(kinds('BLOOM')).toEqual([]);
- expect(kinds('ON A PLATE')).toEqual([]);
+ // On failure, name the measured ratio and the moment, so a backdrop sampled off the plate is visible.
+ expect(kinds('ON A PLATE'), JSON.stringify(check.findings.filter((f) => f.texts.includes('ON A PLATE')))).toEqual([]);
// One finding per problem however many frames showed it, errors first.
expect(new Set(check.findings.map((f) => f.id)).size).toBe(check.findings.length);
expect(check.findings[0].severity).toBe('error');