mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-21 15:24:09 +00:00
Remove Object URL usage for image previews
This commit is contained in:
@@ -177,10 +177,12 @@ const formatTime = (time?: number) => {
|
||||
|
||||
const onProgressPreviewReceived = async ({ detail }: CustomEvent) => {
|
||||
if (props.task.displayStatus === TaskItemDisplayStatus.Running) {
|
||||
if (progressPreviewBlobUrl.value) {
|
||||
URL.revokeObjectURL(progressPreviewBlobUrl.value)
|
||||
const reader = new FileReader()
|
||||
reader.onloadend = () => {
|
||||
if (typeof reader.result !== 'string') return
|
||||
progressPreviewBlobUrl.value = reader.result
|
||||
}
|
||||
progressPreviewBlobUrl.value = URL.createObjectURL(detail)
|
||||
reader.readAsDataURL(detail)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -261,10 +261,6 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
|
||||
const previews = app.nodePreviewImages[nodeLocatorId]
|
||||
if (!previews?.[Symbol.iterator]) return
|
||||
|
||||
for (const url of previews) {
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
delete app.nodePreviewImages[nodeLocatorId]
|
||||
delete nodePreviewImages.value[nodeLocatorId]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user