Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Diagnostic report: keep video and prompt-rewrite reports apart, save one file, zip large ones

Bowen Xuefb9b2bc5f87c
diff --git a/.github/ISSUE_TEMPLATE/report.yml b/.github/ISSUE_TEMPLATE/report.yml
index 52a2cdb..26d0686 100644
--- a/.github/ISSUE_TEMPLATE/report.yml
+++ b/.github/ISSUE_TEMPLATE/report.yml
@@ -13,8 +13,8 @@ body:
id: report
attributes:
label: Diagnostic report / 诊断报告
- description: Please drag the downloaded report (FreeVideo-report-….json) here. In FreeVideo, select Diagnostic report under a finished video. / 请将下载的诊断报告(FreeVideo-report-….json)拖到这里(在 FreeVideo 视频下方点击「诊断报告」即可获得)。
- placeholder: Drop FreeVideo-report-….json here / 将 FreeVideo-report-….json 拖到这里
+ description: Please drag the downloaded report (FreeVideo-report-….json or .zip) here. A link appears when the upload finishes. In FreeVideo, select Diagnostic report under a finished video. / 请将下载的诊断报告(FreeVideo-report-….json 或 .zip,在 FreeVideo 视频下方点击「诊断报告」获得)拖到这里,上传完成后会出现一个链接。
+ placeholder: Drop FreeVideo-report-….json or .zip here / 将 FreeVideo-report-….json 或 .zip 拖到这里
validations:
required: true
- type: input
diff --git a/web/editor_failure.js b/web/editor_failure.js
index d778982..02df4df 100644
--- a/web/editor_failure.js
+++ b/web/editor_failure.js
@@ -76,7 +76,7 @@ export function createEditorFailures({api, state, jobStatuses, reasonText}) {
} else blob = new Blob([JSON.stringify(report(id), null, 2)], {type: 'application/json'});
const latest = receipt(id);
if (!current() || latest?.attempt !== found.attempt || latest?.value.detail !== found.value.detail) return;
- saveReport(blob);
+ await saveReport(blob);
// Use exactly the video's card and submit flow, including no second download.
return showReportTip(bar, anchor, t, {mode: 'downloaded',
submit: () => reportIssue(() => Promise.resolve(blob), productVersion(), {save: false})});
diff --git a/web/generation_progress.js b/web/generation_progress.js
index 351a232..1547c4d 100644
--- a/web/generation_progress.js
+++ b/web/generation_progress.js
@@ -370,14 +370,15 @@ export function createDiagnosticReportControl(t, {api = null, fallback = null, t
}
}
const report = el('button', 'fv-report-download fv-quiet'); report.type = 'button'; report.hidden = true;
- let reportId = null, revision = 0;
+ // A finished video's report is fetched once and kept: the file saved and the one sent are the same.
+ let reportId = null, revision = 0, pinned = false, pinnedBlob = null;
report.textContent = label();
function updateReport(message) {
if (message.new_request === true || message.overall?.reset === true || message.reset === true && !message.phase) {
- reportId = null; revision++; report.hidden = true;
+ reportId = null; revision++; report.hidden = true; pinned = false; pinnedBlob = null;
}
if (typeof message.report_id === 'string' && /^[a-f0-9]{32}$/.test(message.report_id)) {
- if (reportId !== message.report_id) { revision++; report.disabled = false; report.textContent = label(); }
+ if (reportId !== message.report_id) { revision++; pinned = false; pinnedBlob = null; report.disabled = false; report.textContent = label(); }
reportId = message.report_id;
}
report.hidden = !reportId && !fallback;
@@ -385,15 +386,18 @@ export function createDiagnosticReportControl(t, {api = null, fallback = null, t
}
async function fetchReport() {
if (reportId) {
- const path = `/freevideo/report/${reportId}`;
+ if (pinned && pinnedBlob) return pinnedBlob;
+ const id = reportId, path = `/freevideo/report/${id}`;
const response = await (api ? api.fetchApi(path) : fetch(path));
if (!response.ok) throw new Error('Report unavailable');
- return response.blob();
+ const blob = await response.blob();
+ if (pinned && reportId === id) pinnedBlob = blob;
+ return blob;
}
if (fallback) return fallback();
throw new Error('Report unavailable');
}
- async function downloadReport() { saveReport(await fetchReport()); }
+ async function downloadReport() { await saveReport(await fetchReport()); }
report.onclick = async () => {
if (report.disabled || report.hidden) return;
const current = revision;
@@ -409,7 +413,7 @@ export function createDiagnosticReportControl(t, {api = null, fallback = null, t
if (current === revision) report.textContent = t('Report unavailable · retry', '报告暂不可用 · 重试');
} finally { if (current === revision) report.disabled = false; }
};
- return {report, updateReport, fetchReport, downloadReport, hasReport: () => reportId !== null};
+ return {report, updateReport, fetchReport, downloadReport, hasReport: () => reportId !== null, pin: () => { pinned = true; }};
}
export function createGenerationProgress(t, now = () => Date.now(), {compact = false, api = null, onLayout = null} = {}) {
@@ -1063,6 +1067,6 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = f
mini_fraction: visible && !mini.hidden && miniMode === 'determinate' ? miniShown : null,
mini_shimmer: visible && !mini.hidden && miniShimmer};
}
- return {element, stall, report, updateReport, fetchReport, downloadReport, hasReport: diagnostic.hasReport, update, hide, dispose: hide,
+ return {element, stall, report, updateReport, fetchReport, downloadReport, hasReport: diagnostic.hasReport, pinReport: diagnostic.pin, update, hide, dispose: hide,
noticeCount: () => trims.size, stallShown: () => !stall.hidden, percentShown: () => !heading.hidden, snapshot};
}
diff --git a/web/report_issue.js b/web/report_issue.js
index 19932c2..a57fb8d 100644
--- a/web/report_issue.js
+++ b/web/report_issue.js
@@ -39,15 +39,61 @@ export function reportIssueURL(report, productVersion = null) {
// Each download is named by when it was saved, so saving reports again never
// leaves "video.debug (1).json"-style copies; the card names the file just saved.
let savedName = null;
-export function reportFileName(date = new Date()) {
+export function reportFileName(date = new Date(), extension = 'json') {
const pad = value => String(value).padStart(2, '0');
return `FreeVideo-report-${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}`
- + `-${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}.json`;
+ + `-${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}.${extension}`;
}
-export function saveReport(blob) {
- const url = URL.createObjectURL(blob);
- savedName = reportFileName();
+// A report larger than this is saved as a zip with the same name.
+export const ZIP_THRESHOLD = 512 * 1024;
+
+const CRC_TABLE = (() => {
+ const table = new Uint32Array(256);
+ for (let n = 0; n < 256; n++) { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; table[n] = c >>> 0; }
+ return table;
+})();
+function crc32(bytes) {
+ let c = 0xffffffff;
+ for (let i = 0; i < bytes.length; i++) c = CRC_TABLE[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);
+ return (c ^ 0xffffffff) >>> 0;
+}
+async function deflate(bytes) {
+ if (typeof CompressionStream !== 'function') return null;
+ try {
+ const stream = new Blob([bytes]).stream().pipeThrough(new CompressionStream('deflate-raw'));
+ return new Uint8Array(await new Response(stream).arrayBuffer());
+ } catch { return null; }
+}
+
+// One file in a zip: deflated when the browser can, stored otherwise.
+export async function zipReport(blob, name) {
+ const data = new Uint8Array(await blob.arrayBuffer());
+ const packed = await deflate(data);
+ const body = packed && packed.length < data.length ? packed : data, method = body === data ? 0 : 8;
+ const file = new TextEncoder().encode(name), crc = crc32(data);
+ const local = new DataView(new ArrayBuffer(30)), central = new DataView(new ArrayBuffer(46)), end = new DataView(new ArrayBuffer(22));
+ local.setUint32(0, 0x04034b50, true); local.setUint16(4, 20, true); local.setUint16(6, 0x0800, true); local.setUint16(8, method, true);
+ local.setUint16(12, 0x21, true); // 1980-01-01, so the file is the same each time
+ local.setUint32(14, crc, true); local.setUint32(18, body.length, true); local.setUint32(22, data.length, true); local.setUint16(26, file.length, true);
+ central.setUint32(0, 0x02014b50, true); central.setUint16(4, 20, true); central.setUint16(6, 20, true); central.setUint16(8, 0x0800, true);
+ central.setUint16(10, method, true); central.setUint16(14, 0x21, true); central.setUint32(16, crc, true);
+ central.setUint32(20, body.length, true); central.setUint32(24, data.length, true); central.setUint16(28, file.length, true);
+ const centralSize = 46 + file.length, centralStart = 30 + file.length + body.length;
+ end.setUint32(0, 0x06054b50, true); end.setUint16(8, 1, true); end.setUint16(10, 1, true);
+ end.setUint32(12, centralSize, true); end.setUint32(16, centralStart, true);
+ return new Blob([local, file, body, central, file, end], {type: 'application/zip'});
+}
+
+// Saves the report; a large one goes into a zip first. Resolves to the file name.
+export async function saveReport(blob) {
+ const date = new Date();
+ let name = reportFileName(date), out = blob;
+ if (blob.size > ZIP_THRESHOLD) {
+ try { out = await zipReport(blob, name); name = reportFileName(date, 'zip'); } catch { out = blob; }
+ }
+ const url = URL.createObjectURL(out);
+ savedName = name;
const link = document.createElement('a'); link.href = url; link.download = savedName;
document.body.append(link); link.click(); link.remove();
setTimeout(() => URL.revokeObjectURL(url), 1000);
@@ -59,7 +105,7 @@ export function saveReport(blob) {
// saved file in. Resolves to the form's address.
export async function reportIssue(fetchReport, productVersion = null, {save = true, open = url => window.open(url, '_blank', 'noopener')} = {}) {
const blob = await fetchReport();
- if (save) saveReport(blob);
+ if (save) await saveReport(blob);
let report = null;
try { report = JSON.parse(await blob.text()); } catch { /* The form still opens, without prefilled fields. */ }
const address = reportIssueURL(report, productVersion);
@@ -129,7 +175,10 @@ export function showReportTip(bar, anchor, t, {mode = 'invite', submit, onHide =
tip.classList.add('fv-report-tip-sent'); anchor.classList.remove('fv-report-attention');
mark.replaceChildren(glyph('done'));
title.textContent = t('Last step', '最后一步');
- lead.textContent = savedName
+ lead.textContent = savedName?.endsWith('.zip')
+ ? t(`The report is large, so it was saved as ${savedName}. Please drag it into "Diagnostic report", then select Submit new issue.`,
+ `报告较大,已保存为 ${savedName}。请将它拖入「诊断报告」,再点击 Submit new issue 即可。`)
+ : savedName
? t(`Please drag ${savedName} into "Diagnostic report", then select Submit new issue.`,
`请将 ${savedName} 拖入「诊断报告」,再点击 Submit new issue 即可。`)
: t('Please drag the downloaded report into "Diagnostic report", then select Submit new issue.',
diff --git a/web/studio.js b/web/studio.js
index cc40722..4d16499 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -571,7 +571,8 @@ export function openStudio(node, {extendFrom = null} = {}) {
let requestAssets = null;
const enhancer = createPromptEnhancer({node, input: prompt, editor: promptEditor, api, t, starter,
prepare: text => expandCast(text, mediaRows(node), {active: !extension.source}).text,
- onReport: row => { node.freevideoReportId = row.report_id; progress.updateReport(row); },
+ // The rewrite has its own report; the video's report entry is not touched.
+ onReport: row => { node.freevideoPromptReportId = row.rewrite_report_id || row.report_id; },
onChange: () => { rememberPromptDraft(api, node); requestAssets?.refresh(); },
setText: text => { set(node, 'text', text || (untouched() ? starter : '')); placeholder(); }, context: () => {
const items = referenceItems(node);
@@ -1022,13 +1023,22 @@ export function openStudio(node, {extendFrom = null} = {}) {
cleanup.push(() => recent.dispose());
// A run this window watched. Its result can arrive before or after the
// final progress message, and more than once; the tip stays with that video.
- let reportTipTimer = null, watchedRun = false, reportTipFor = null;
+ let reportTipTimer = null, watchedRun = false, reportTipFor = null, shownReport = null;
// chosen: a video picked from Recent videos. It only changes the picture; a run in progress keeps its progress.
function showResult(r, {chosen = false} = {}) {
if (!r?.video || disposed) return; result = r;
recent.setSelected(r.video);
refreshEffortEstimate(true);
- progress.updateReport({report_id: node.freevideoReportId});
+ // The report belongs to the video that run made; a video picked from Recent videos
+ // shows its own report, or none when this window never saw its run.
+ const reports = node.freevideoVideoReports || (node.freevideoVideoReports = new Map());
+ if (!chosen && node.freevideoReportId) reports.set(r.video, node.freevideoReportId);
+ const wanted = reports.get(r.video) || null;
+ if (!(chosen && busy) && wanted !== shownReport) {
+ shownReport = wanted; progress.updateReport({new_request: true});
+ if (wanted) progress.updateReport({report_id: wanted});
+ }
+ if (wanted && !(chosen && busy)) progress.pinReport();
stage.querySelector('video')?.pause(); stageMedia.replaceChildren();
const video = el('video'); video.src = view(r.video, 'output') + (r.version ? `&fv=${encodeURIComponent(r.version)}` : ''); video.controls = true; video.preload = 'metadata'; video.playsInline = true; stageMedia.append(video);
video.addEventListener('error', () => {