From 80990875192ab8dbc68dd0990743aa55af5d49fb Mon Sep 17 00:00:00 2001 From: Linda Paiste Date: Wed, 7 Jun 2023 20:53:08 -0500 Subject: [PATCH 1/2] Revoke outdated blob urls. --- client/modules/Preview/EmbedFrame.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/modules/Preview/EmbedFrame.jsx b/client/modules/Preview/EmbedFrame.jsx index 43f229fa2d..1347a1785d 100644 --- a/client/modules/Preview/EmbedFrame.jsx +++ b/client/modules/Preview/EmbedFrame.jsx @@ -1,3 +1,4 @@ +import blobUtil from 'blob-util'; import PropTypes from 'prop-types'; import React, { useRef, useEffect, useMemo } from 'react'; import styled from 'styled-components'; @@ -276,6 +277,7 @@ function getHtmlFile(files) { function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) { const iframe = useRef(); const htmlFile = useMemo(() => getHtmlFile(files), [files]); + const srcRef = useRef(); useEffect(() => { const unsubscribe = registerFrame( @@ -300,6 +302,10 @@ function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) { content: htmlDoc }; const htmlUrl = createBlobUrl(generatedHtmlFile); + if (srcRef.current) { + blobUtil.revokeObjectURL(srcRef.current); + } + srcRef.current = htmlUrl; // BRO FOR SOME REASON YOU HAVE TO DO THIS TO GET IT TO WORK ON SAFARI setTimeout(() => { doc.src = htmlUrl; From a418d430a991bf6f0cc62d4150e9f690ddd36e7d Mon Sep 17 00:00:00 2001 From: Linda Paiste Date: Wed, 7 Jun 2023 21:07:38 -0500 Subject: [PATCH 2/2] Revoke blob inside setTimeout. --- client/modules/Preview/EmbedFrame.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/modules/Preview/EmbedFrame.jsx b/client/modules/Preview/EmbedFrame.jsx index 1347a1785d..7c98e7717b 100644 --- a/client/modules/Preview/EmbedFrame.jsx +++ b/client/modules/Preview/EmbedFrame.jsx @@ -302,13 +302,14 @@ function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) { content: htmlDoc }; const htmlUrl = createBlobUrl(generatedHtmlFile); - if (srcRef.current) { - blobUtil.revokeObjectURL(srcRef.current); - } + const toRevoke = srcRef.current; srcRef.current = htmlUrl; // BRO FOR SOME REASON YOU HAVE TO DO THIS TO GET IT TO WORK ON SAFARI setTimeout(() => { doc.src = htmlUrl; + if (toRevoke) { + blobUtil.revokeObjectURL(toRevoke); + } }, 0); } else { doc.src = '';