Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7e67bb4
feat: implement sandboxing to be used for measuring SVGs; add tests
KManolov3 May 10, 2026
116301e
feat: add canonicalize-svg method
KManolov3 May 11, 2026
114ce54
feat: implement measure svg script to be used in sandboxed environment
KManolov3 May 11, 2026
4eeb5d7
feat: use the sandboxing mechanism for svg measurement
KManolov3 May 11, 2026
f99b4f8
feat: update usage of consumers of loadSvgString
KManolov3 May 11, 2026
1438d2a
feat: update setSvg to be awaitable; update usages
KManolov3 May 12, 2026
28e5b2a
fix: lint error
KManolov3 May 12, 2026
a069b29
feat: add tests for the updated usages of svg measurement
KManolov3 May 13, 2026
791124b
Merge branch 'develop' of github.com:scratchfoundation/scratch-editor…
adzhindzhi Jul 6, 2026
ee7378c
fix: package-lock.json after merging develop
adzhindzhi Jul 6, 2026
acdc3ea
feat: add sandboxing when appending to DOM in importSVG
KManolov3 May 15, 2026
1c8fc15
fix: bring back old sanitized snapshot to verify test failures
adzhindzhi Jul 7, 2026
f6fd932
test: force snapshots to be regenerated to check if that resolves tes…
adzhindzhi Jul 7, 2026
1e7abb1
test: try regenerating snapshot on ubuntu:latest
adzhindzhi Jul 7, 2026
5d35241
test: try uploading the snapshots as an artifact
adzhindzhi Jul 7, 2026
5126f7e
fix: use snapshots generated from ci/cd job
adzhindzhi Jul 7, 2026
22f1b9e
fix: make VM await updateSVGSkin now that it's async
adzhindzhi Jul 7, 2026
d026072
fix: tear down the measurement sandbox on inactivity
adzhindzhi Jul 8, 2026
75594d1
fix: issues when uploading SVG wrapped raster images and uploading sp…
adzhindzhi Jul 21, 2026
a5c32d0
feat: pre-load the sandbox iframe early to avoid extensive waiting ti…
adzhindzhi Jul 23, 2026
08536f0
fix: address review points
adzhindzhi Jul 23, 2026
c43cef8
fix: address review points
adzhindzhi Jul 24, 2026
938b73d
fix: trim release commit message to avoid E2BIG failures
adzhindzhi Jul 24, 2026
b8d2fbe
Merge branch 'develop' of github.com:scratchfoundation/scratch-editor…
adzhindzhi Jul 24, 2026
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
151 changes: 139 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions packages/scratch-gui/src/containers/gui.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {compose} from 'redux';
import {connect} from 'react-redux';
import ReactModal from 'react-modal';
import VM from '@scratch/scratch-vm';
import {prewarmPaperSandbox} from '@scratch/scratch-paint';
import {injectIntl} from 'react-intl';
import intlShape from '../lib/intlShape.js';

Expand Down Expand Up @@ -63,11 +64,15 @@ class GUI extends React.Component {
if (this.props.dynamicAssets) {
this.props.onUpdateDynamicAssets(this.props.dynamicAssets);
}
this.maybePrewarmPaperSandbox();
}
componentDidUpdate (prevProps) {
if (this.props.dynamicAssets !== prevProps.dynamicAssets) {
this.props.onUpdateDynamicAssets(this.props.dynamicAssets);
}
// A session may start player-only and later enter the editor; warm the
// paint sandbox on that transition too.
this.maybePrewarmPaperSandbox();
if (this.props.projectId !== prevProps.projectId) {
if (this.props.projectId !== null) {
this.props.onUpdateProjectId(this.props.projectId);
Expand All @@ -84,6 +89,20 @@ class GUI extends React.Component {
this.props.vm.stopAll();
}
}
// Once per editor session, build and warm the Paper.js sandbox during idle
// time so the first costume import in the paint editor is not slowed by the
// iframe creation and Paper.js evaluation cold-start. Skipped in player-only
// sessions, which never open the paint editor.
maybePrewarmPaperSandbox () {
if (this._paperSandboxWarmed || this.props.isPlayerOnly) return;
this._paperSandboxWarmed = true;
// Some browsers (e.g. Safari) don't support requestIdleCallback, so fall back to setTimeout.
const scheduleIdle = window.requestIdleCallback ?
window.requestIdleCallback.bind(window) :

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've likely already checked, but the requestIdleCallback doesn't have anything to do with the Chrome vs Safari performance differences, correct? Paper.js has already loaded by the time we open the Costumes tab in either case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not related. It generally get's picked up faster on Safari, because it doesn't wait for idle windows, but picks it up immediately after the current task finishes. However, that all happens while the editor is still loading, and especially on large projects, where we fetch multiple assets - all of this is finished long before we navigate to the Costumes tab.

callback => setTimeout(() => callback(), 0);

scheduleIdle(() => prewarmPaperSandbox());
}
render () {
if (this.props.isError) {
throw new Error(
Expand Down Expand Up @@ -139,6 +158,7 @@ GUI.propTypes = {
intl: intlShape,
isError: PropTypes.bool,
isLoading: PropTypes.bool,
isPlayerOnly: PropTypes.bool,
isShowingProject: PropTypes.bool,
isTotallyNormal: PropTypes.bool,
loadingStateVisible: PropTypes.bool,
Expand Down
Loading
Loading