Skip to content

Commit 740203b

Browse files
authored
Merge pull request #2235 from lindapaiste/fix/revoke-blob
Revoke outdated Blob URLs
2 parents 680bffb + 5d4c746 commit 740203b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

client/modules/Preview/EmbedFrame.jsx

Lines changed: 7 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';
@@ -272,6 +273,7 @@ function getHtmlFile(files) {
272273
function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) {
273274
const iframe = useRef();
274275
const htmlFile = useMemo(() => getHtmlFile(files), [files]);
276+
const srcRef = useRef();
275277

276278
useEffect(() => {
277279
const unsubscribe = registerFrame(
@@ -296,9 +298,14 @@ function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) {
296298
content: htmlDoc
297299
};
298300
const htmlUrl = createBlobUrl(generatedHtmlFile);
301+
const toRevoke = srcRef.current;
302+
srcRef.current = htmlUrl;
299303
// BRO FOR SOME REASON YOU HAVE TO DO THIS TO GET IT TO WORK ON SAFARI
300304
setTimeout(() => {
301305
doc.src = htmlUrl;
306+
if (toRevoke) {
307+
blobUtil.revokeObjectURL(toRevoke);
308+
}
302309
}, 0);
303310
} else {
304311
doc.src = '';

0 commit comments

Comments
 (0)