Remove Object URL usage for image previews

This commit is contained in:
Austin Mroz
2025-11-01 16:39:18 -07:00
parent dffb07c745
commit a7e8f948a6
3 changed files with 15 additions and 17 deletions

View File

@@ -719,18 +719,18 @@ export class ComfyApp {
api.addEventListener('b_preview_with_metadata', ({ detail }) => {
// Enhanced preview with explicit node context
const { blob, displayNodeId } = detail
const { setNodePreviewsByExecutionId, revokePreviewsByExecutionId } =
useNodeOutputStore()
// Ensure clean up if `executing` event is missed.
revokePreviewsByExecutionId(displayNodeId)
const blobUrl = URL.createObjectURL(blob)
// Preview cleanup is handled in progress_state event to support multiple concurrent previews
const { setNodePreviewsByExecutionId } = useNodeOutputStore()
const reader = new FileReader()
const nodeParents = displayNodeId.split(':')
for (let i = 1; i <= nodeParents.length; i++) {
setNodePreviewsByExecutionId(nodeParents.slice(0, i).join(':'), [
blobUrl
])
reader.onloadend = () => {
if (typeof reader.result !== 'string') return
for (let i = 1; i <= nodeParents.length; i++) {
setNodePreviewsByExecutionId(nodeParents.slice(0, i).join(':'), [
reader.result
])
}
}
reader.readAsDataURL(blob)
})
api.init()