Skip to content

Commit 8099087

Browse files
committed
Revoke outdated blob urls.
1 parent 7212f76 commit 8099087

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

client/modules/Preview/EmbedFrame.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import blobUtil from 'blob-util';
12
import PropTypes from 'prop-types';
23
import React, { useRef, useEffect, useMemo } from 'react';
34
import styled from 'styled-components';
@@ -276,6 +277,7 @@ function getHtmlFile(files) {
276277
function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) {
277278
const iframe = useRef();
278279
const htmlFile = useMemo(() => getHtmlFile(files), [files]);
280+
const srcRef = useRef();
279281

280282
useEffect(() => {
281283
const unsubscribe = registerFrame(
@@ -300,6 +302,10 @@ function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) {
300302
content: htmlDoc
301303
};
302304
const htmlUrl = createBlobUrl(generatedHtmlFile);
305+
if (srcRef.current) {
306+
blobUtil.revokeObjectURL(srcRef.current);
307+
}
308+
srcRef.current = htmlUrl;
303309
// BRO FOR SOME REASON YOU HAVE TO DO THIS TO GET IT TO WORK ON SAFARI
304310
setTimeout(() => {
305311
doc.src = htmlUrl;

0 commit comments

Comments
 (0)