Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/core/dom-renderer/domRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,17 @@ function updateNodeStyles(node: DOMNode | DOMText) {
// Renderer 1.8 widened `src` to `string | Blob | ImageData`; the DOM
// renderer only paints string URLs.
rawImgSrc = props.src;
} else if (typeof Blob !== 'undefined' && props.src instanceof Blob) {
if (node.blobSrc !== props.src) {
node.clearBlobUrl();
node.blobSrc = props.src;
node.blobUrl = URL.createObjectURL(props.src);
}
rawImgSrc = node.blobUrl;
}

if (node.blobUrl && rawImgSrc !== node.blobUrl) {
node.clearBlobUrl();
}

if (rawImgSrc) {
Expand Down Expand Up @@ -1354,6 +1365,9 @@ export class DOMNode extends EventEmitter implements IRendererNode {
lazyImageSubTextureProps:
| InstanceType<lng.TextureMap['SubTexture']>['props']
| null = null;

blobUrl: string | null = null;
blobSrc: Blob | null = null;
boundsDirty = true;
children = new Set<DOMNode>();
/** Cached result of the last updateNodeStyles call — avoids redundant setAttribute writes. */
Expand Down Expand Up @@ -1401,11 +1415,21 @@ export class DOMNode extends EventEmitter implements IRendererNode {
// Like CoreNode, destroying a node marks its whole subtree destroyed.
private markDestroyed() {
this.destroyed = true;
this.clearBlobUrl();
for (const child of this.children) {
child.markDestroyed();
}
}

// clears blob logic
clearBlobUrl() {
if (this.blobUrl) {
URL.revokeObjectURL(this.blobUrl);
this.blobSrc = null;
this.blobUrl = null;
}
}

get parent() {
return this.props.parent;
}
Expand Down