{"record":{"id":"86b4330ca6eabcf8","repo":"siyuan-note/siyuan","slug":"window-siyuan-languages-exportfilesavefailed","errorCode":null,"errorMessage":"window.siyuan.languages.exportFileSaveFailed","messagePattern":"window\\.siyuan\\.languages\\.exportFileSaveFailed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/protyle/export/util.ts","lineNumber":181,"sourceCode":"        const oldHeight = containerElement.style.height;\n        const oldMaxHeight = containerElement.style.maxHeight;\n        const oldWidth = containerElement.style.width;\n        // 导出时让内容完整展开，避免移动端对话框的最大高度限制截断长图。\n        containerElement.style.height = \"\";\n        containerElement.style.maxHeight = \"none\";\n        /// #if MOBILE\n        containerElement.style.width = \"100vw\";\n        /// #endif\n        const contentElement = exportDialog.element.querySelector(\".b3-dialog__content\") as HTMLElement;\n        const oldOverflow = contentElement.style.overflow;\n        contentElement.style.overflow = \"hidden\";\n        if (!copyOnly) {\n            setStorageVal(Constants.LOCAL_EXPORTIMG, window.siyuan.storage[Constants.LOCAL_EXPORTIMG]);\n        }\n        try {\n            const blob = await renderImageBlob();\n            if (!blob) {\n                throw new Error(window.siyuan.languages.exportFileSaveFailed);\n            }\n            if (type === \"copy\") {\n                let copied: boolean;\n                if (isInAndroid()) {\n                    const response = await uploadImageBlob(blob);\n                    copied = response.code === 0;\n                    if (copied) {\n                        copyPNGByLink(response.data.file);\n                    }\n                } else {\n                    copied = await writePNGBlob(blob);\n                }\n                hideMessage(msgId);\n                if (!copied) {\n                    return;\n                }\n                showMessage(window.siyuan.languages.copied);\n            } else {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/app/src/protyle/export/util.ts#L163-L199","documentation":"outputImage renders the editor (or a block) to a PNG blob; if renderImageBlob returns null/undefined the export cannot proceed and this error is thrown with the localized 'export file save failed' message, which the surrounding catch surfaces to the user.","triggerScenarios":"Calling exportImage/refreshPreview when renderImageBlob() yields null — typically because the target element has zero size, is hidden/detached, html2canvas-style rendering failed, or fonts/images inside the block failed to load.","commonSituations":"Exporting an empty or invisible block; exporting before layout completes; browser rendering limits (canvas too large for very tall documents, memory pressure); headless environments where rendering silently fails.","solutions":["Retry the export after ensuring the block is visible and the layout has finished","Reduce the exported region (smaller block/document) to avoid canvas size/memory limits","Check the dev console for renderer (canvas/html2canvas) errors preceding the null blob","Verify the browser is not in a headless/limited environment where rendering APIs are unavailable"],"exampleFix":"// before\nconst blob = await renderImageBlob();\n// after\nconst blob = await renderImageBlob();\nif (!blob) { showMessage(window.siyuan.languages.exportFileSaveFailed); return; }","handlingStrategy":"validation","validationCode":"if (!element || element.offsetWidth === 0 || element.offsetHeight === 0) return null; // skip export","typeGuard":"const hasRenderableBlob = (b: Blob | null | undefined): b is Blob => b instanceof Blob && b.size > 0;","tryCatchPattern":"try { await outputImage(...); } catch (e) { hideMessage(msgId); showMessage(window.siyuan.languages.exportFileSaveFailed); }","preventionTips":["Ensure the target block is visible and layout-complete before export","Avoid exporting extremely tall content that exceeds canvas limits","Check console for renderer failures that produce a null blob"],"tags":["export","image","rendering"],"backgroundTag":"internal-invariant-violation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}