diff --git a/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts b/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts index 644670aad..69a5fadcd 100644 --- a/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts +++ b/frontend/src/components/common/renderer-iframe/hooks/use-force-render-page-url-on-iframe-load-callback.ts @@ -43,7 +43,8 @@ export const useForceRenderPageUrlOnIframeLoadCallback = ( redirectionInProgress.current = false log.debug('Redirect complete') } else { - log.warn(`Navigated away from unknown URL. Forcing back to ${forcedUrl}`) + const oldUrl = frame.src === '' ? '(none)' : frame.src + log.warn(`Navigated away from unknown URL. Was ${oldUrl}. Forcing back to ${forcedUrl}`) onNavigateAway?.() redirectionInProgress.current = true frame.src = forcedUrl diff --git a/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx b/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx index 4ca0364a1..3b401773b 100644 --- a/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx +++ b/frontend/src/components/common/renderer-iframe/renderer-iframe.tsx @@ -37,8 +37,6 @@ export interface RendererIframeProps extends Omit = ({ const [rendererReady, setRendererReady] = useState(false) const frameReference = useRef(null) const iframeCommunicator = useEditorToRendererCommunicator() + const log = useMemo(() => new Logger(`RendererIframe[${iframeCommunicator.getUuid()}]`), [iframeCommunicator]) + const resetRendererReady = useCallback(() => { log.debug('Reset render status') setRendererReady(false) - }, []) + }, [log]) const onIframeLoad = useForceRenderPageUrlOnIframeLoadCallback(frameReference, resetRendererReady) const [frameHeight, setFrameHeight] = useState(0) + useEffect(() => { + if (rendererReady) { + log.info('Renderer Ready!') + } else { + log.info('Renderer not ready') + } + }, [log, rendererReady]) + useEffect(() => { onRendererStatusChange?.(rendererReady) }, [onRendererStatusChange, rendererReady]) - useEffect(() => () => setRendererReady(false), [iframeCommunicator]) + useEffect( + () => () => { + log.debug('Component ended') + setRendererReady(false) + }, + [iframeCommunicator, log] + ) useEffect(() => { if (!rendererReady) { @@ -138,7 +152,7 @@ export const RendererIframe: React.FC = ({ } }) setRendererReady(true) - }, [iframeCommunicator, rendererType]) + }, [iframeCommunicator, log, rendererType]) ) useEffectOnRenderTypeChange(rendererType, onIframeLoad) diff --git a/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts b/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts index 39644d438..07c01378c 100644 --- a/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts +++ b/frontend/src/components/render-page/window-post-message-communicator/editor-to-renderer-communicator.ts @@ -19,7 +19,7 @@ export class EditorToRendererCommunicator extends WindowPostMessageCommunicator< EditorToRendererMessageType, CommunicationMessages > { - protected createLogger(): Logger { - return new Logger('EditorToRendererCommunicator') + protected createLogger(uuid: string): Logger { + return new Logger(`EditorToRendererCommunicator[${uuid}]`) } } diff --git a/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts b/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts index ee04f0694..0faa39bda 100644 --- a/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts +++ b/frontend/src/components/render-page/window-post-message-communicator/renderer-to-editor-communicator.ts @@ -19,7 +19,7 @@ export class RendererToEditorCommunicator extends WindowPostMessageCommunicator< RendererToEditorMessageType, CommunicationMessages > { - protected createLogger(): Logger { - return new Logger('RendererToEditorCommunicator') + protected createLogger(uuid: string): Logger { + return new Logger(`RendererToEditorCommunicator[${uuid}]`) } } diff --git a/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts b/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts index 70004abfa..be3dbed33 100644 --- a/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts +++ b/frontend/src/components/render-page/window-post-message-communicator/window-post-message-communicator.ts @@ -45,14 +45,14 @@ export abstract class WindowPostMessageCommunicator< ) { this.boundListener = this.handleEvent.bind(this) this.communicationEnabled = false - this.log = this.createLogger() + this.log = this.createLogger(uuid) } public getUuid(): string { return this.uuid } - protected abstract createLogger(): Logger + protected abstract createLogger(uuid: string): Logger /** * Registers the event listener on the current global {@link window}.