mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +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) => {
|
const onProgressPreviewReceived = async ({ detail }: CustomEvent) => {
|
||||||
if (props.task.displayStatus === TaskItemDisplayStatus.Running) {
|
if (props.task.displayStatus === TaskItemDisplayStatus.Running) {
|
||||||
if (progressPreviewBlobUrl.value) {
|
const reader = new FileReader()
|
||||||
URL.revokeObjectURL(progressPreviewBlobUrl.value)
|
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 }) => {
|
api.addEventListener('b_preview_with_metadata', ({ detail }) => {
|
||||||
// Enhanced preview with explicit node context
|
// Enhanced preview with explicit node context
|
||||||
const { blob, displayNodeId } = detail
|
const { blob, displayNodeId } = detail
|
||||||
const { setNodePreviewsByExecutionId, revokePreviewsByExecutionId } =
|
const { setNodePreviewsByExecutionId } = useNodeOutputStore()
|
||||||
useNodeOutputStore()
|
const reader = new FileReader()
|
||||||
// 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 nodeParents = displayNodeId.split(':')
|
const nodeParents = displayNodeId.split(':')
|
||||||
for (let i = 1; i <= nodeParents.length; i++) {
|
reader.onloadend = () => {
|
||||||
setNodePreviewsByExecutionId(nodeParents.slice(0, i).join(':'), [
|
if (typeof reader.result !== 'string') return
|
||||||
blobUrl
|
for (let i = 1; i <= nodeParents.length; i++) {
|
||||||
])
|
setNodePreviewsByExecutionId(nodeParents.slice(0, i).join(':'), [
|
||||||
|
reader.result
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
reader.readAsDataURL(blob)
|
||||||
})
|
})
|
||||||
|
|
||||||
api.init()
|
api.init()
|
||||||
|
|||||||
@@ -261,10 +261,6 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
|
|||||||
const previews = app.nodePreviewImages[nodeLocatorId]
|
const previews = app.nodePreviewImages[nodeLocatorId]
|
||||||
if (!previews?.[Symbol.iterator]) return
|
if (!previews?.[Symbol.iterator]) return
|
||||||
|
|
||||||
for (const url of previews) {
|
|
||||||
URL.revokeObjectURL(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
delete app.nodePreviewImages[nodeLocatorId]
|
delete app.nodePreviewImages[nodeLocatorId]
|
||||||
delete nodePreviewImages.value[nodeLocatorId]
|
delete nodePreviewImages.value[nodeLocatorId]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user