Skip to content

Revoke outdated Blob URLs #2235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 29, 2024
Merged
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
7 changes: 7 additions & 0 deletions client/modules/Preview/EmbedFrame.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -272,6 +273,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(
Expand All @@ -296,9 +298,14 @@ function EmbedFrame({ files, isPlaying, basePath, gridOutput, textOutput }) {
content: htmlDoc
};
const htmlUrl = createBlobUrl(generatedHtmlFile);
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 = '';
Expand Down