WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit deff74d

Browse files
committed
Fix the 3D editor not restarted after a lost WebGL context when on the 2D editor
Don't show in changelog
1 parent 5e97170 commit deff74d

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

newIDE/app/src/ExportAndShare/BrowserExporters/BrowserPreview/BrowserPreviewDebuggerServer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class BrowserPreviewDebuggerServer {
103103
if (event.origin !== previewOrigin) return;
104104

105105
const id = getDebuggerIdForPreviewWindow(event.source);
106-
if (id === null) return; // Could not find the id of this preview window.
106+
if (id === null) {
107+
return; // Could not find the id of this preview window.
108+
}
107109

108110
try {
109111
const parsedMessage = JSON.parse(event.data);

newIDE/app/src/SceneEditor/index.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,23 @@ export default class SceneEditor extends React.Component<Props, State> {
369369
onConnectionErrored: () => {},
370370
onServerStateChanged: () => {},
371371
onHandleParsedMessage: ({ id, parsedMessage }) => {
372-
if (
373-
this.props.gameEditorMode !== 'embedded-game' ||
374-
parsedMessage.editorId !== this.props.editorId
375-
) {
372+
if (parsedMessage.editorId !== this.props.editorId) {
373+
return; // Message is not for this editor - ignore it.
374+
}
375+
376+
if (parsedMessage.command === 'notifyGraphicsContextLost') {
377+
// Even if the in0game editor is not visible, a lost context needs
378+
// to have the in-game editor restarted as it is impossible to use for the user.
379+
console.info(
380+
'Embedded game frame notified the graphics context was lost, restarting the editor...'
381+
);
382+
this.props.onRestartInGameEditor(
383+
'relaunched-because-graphics-context-lost'
384+
);
385+
}
386+
387+
// The rest of the messages are only relevant when the embedded game editor is visible.
388+
if (this.props.gameEditorMode !== 'embedded-game') {
376389
return;
377390
}
378391
if (parsedMessage.command === 'updateInstances') {
@@ -398,15 +411,6 @@ export default class SceneEditor extends React.Component<Props, State> {
398411
this.paste();
399412
} else if (parsedMessage.command === 'cut') {
400413
this.cutSelection();
401-
} else if (parsedMessage.command === 'notifyGraphicsContextLost') {
402-
if (this.props.onRestartInGameEditor) {
403-
console.info(
404-
'Embedded game frame notified the graphics context was lost, restarting the editor...'
405-
);
406-
this.props.onRestartInGameEditor(
407-
'relaunched-because-graphics-context-lost'
408-
);
409-
}
410414
}
411415
},
412416
}

0 commit comments

Comments
 (0)