From bd7f254d460a93ce639da1d1c998560647cee560 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:50:13 +0000 Subject: [PATCH 1/3] Show 95th percentile load times and load player assets from R2 The admin load time chart, tile, daily table and CSV, and the project diagnostics card, now show the 95th percentile instead of the mean, so a single load left in a background tab no longer swamps a day. Loads that spent any time hidden no longer report a duration at all. Assets are named by their content, so a cached copy is now used without revalidating it. Repeat visits skip the network for every asset instead of sending an API request, a redirect and a 304 per asset after five minutes. When the API offers an asset mirror, players fetch assets straight from it and fall back to the API only for assets the mirror does not have yet. That halves the requests for a cold load and takes them off the API server. --- package.json | 2 +- src/community/api/urls.js | 1 + src/community/pages/ManageProject.jsx | 2 +- src/community/pages/Project.jsx | 1 + src/community/pages/admin/StatsOverview.jsx | 22 ++++---- .../pages/project/ProjectPreview.jsx | 5 +- .../pages/project/use-embed-bridges.js | 10 ++-- src/community/translations/_sources.json | 40 +++++++------- src/community/translations/en.json | 12 ++-- src/lib/community/cached-fetch.js | 12 ++-- src/lib/components/project-fetcher-hoc.jsx | 15 +++-- src/lib/persistence/storage.js | 37 +++++++------ src/playground/embed.jsx | 8 ++- test/unit/community-cached-fetch.test.js | 27 +++++++++ .../community-embed-fetch-bridge.test.jsx | 38 ++++++++++++- test/unit/community-embed-url.test.js | 17 ++++++ test/unit/mistwarp-asset-mirror.test.js | 55 +++++++++++++++++++ 17 files changed, 229 insertions(+), 75 deletions(-) create mode 100644 test/unit/mistwarp-asset-mirror.test.js diff --git a/package.json b/package.json index 33ea0007957..b857f2e0b2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scratch-gui", - "version": "3.16.2", + "version": "3.17.0", "private": true, "description": "MistWarp editor, player, and community site", "author": "MistWarp contributors", diff --git a/src/community/api/urls.js b/src/community/api/urls.js index 15a35aed259..d91130990cc 100644 --- a/src/community/api/urls.js +++ b/src/community/api/urls.js @@ -88,6 +88,7 @@ export const embedUrl = (project, { const params = new URLSearchParams(); params.set('project_url', project.projectJsonUrl); params.set('mw_assets', project.assetsBase); + if (project.assetsMirrorBase) params.set('mw_assets_mirror', project.assetsMirrorBase); if (bridge) params.set('mw_bridge', '1'); if (profilePreview) params.set('mw_profile_preview', '1'); if (project.id) params.set('platform_project', project.id); diff --git a/src/community/pages/ManageProject.jsx b/src/community/pages/ManageProject.jsx index 1d17fbd325d..48b4e83c1da 100644 --- a/src/community/pages/ManageProject.jsx +++ b/src/community/pages/ManageProject.jsx @@ -824,7 +824,7 @@ const ManageProject = () => {
{diagnostics.counts.load || 0}{communityText('Loads')}
{diagnostics.counts.start || 0}{communityText('Green flags')}
{diagnostics.counts.crash || 0}{communityText('Errors')}
-
{communityText('{value1} ms', {value1: Math.round(diagnostics.averageLoadMs || 0)})}{communityText('Average load')}
+
{communityText('{value1} ms', {value1: Math.round(diagnostics.p95LoadMs || 0)})}{communityText('95th percentile load')}
) : diagnosticsError ? ( {diagnosticsError} diff --git a/src/community/pages/Project.jsx b/src/community/pages/Project.jsx index 3bf181413eb..7461fedecc6 100644 --- a/src/community/pages/Project.jsx +++ b/src/community/pages/Project.jsx @@ -651,6 +651,7 @@ const Project = () => { project.id, project.projectJsonUrl, project.assetsBase, + project.assetsMirrorBase, Boolean(unsandboxed), Boolean(themeAllowed) ]); diff --git a/src/community/pages/admin/StatsOverview.jsx b/src/community/pages/admin/StatsOverview.jsx index 9f1b5d0a291..796f2cbcb32 100644 --- a/src/community/pages/admin/StatsOverview.jsx +++ b/src/community/pages/admin/StatsOverview.jsx @@ -115,7 +115,7 @@ const StatsOverview = ({view}) => { const userSeries = buildSeries(stats.usersByDay, days); const loginSeries = buildSeries(stats.loginsByDay, days); const loadSeries = buildSeries(stats.loadsByDay, days); - const loadTimeSeries = buildSeries(stats.averageLoadMsByDay, days, stats.loadSamplesByDay); + const loadTimeSeries = buildSeries(stats.p95LoadMsByDay, days, stats.loadSamplesByDay); const startSeries = buildSeries(stats.startsByDay, days); const crashSeries = buildSeries(stats.crashesByDay, days); const dailyRows = projectSeries.map((projectPoint, index) => ({ @@ -125,7 +125,7 @@ const StatsOverview = ({view}) => { users: userSeries[index].value, sessions: loginSeries[index].value, loads: loadSeries[index].value, - averageLoadMs: loadTimeSeries[index].value, + p95LoadMs: loadTimeSeries[index].value, loadSamples: loadTimeSeries[index].samples, starts: startSeries[index].value, crashes: crashSeries[index].value @@ -140,8 +140,8 @@ const StatsOverview = ({view}) => { const deviceLoads = Object.values(stats.loadsByDevice || {}) .reduce((total, value) => total + Number(value || 0), 0); const exportDailyData = () => { - const headings = ['Date', 'Projects uploaded', 'Projects updated', 'Users joined', 'Current sessions created', 'Player loads', 'Average load ms', 'Load samples', 'Player starts', 'Crashes']; - const lines = dailyRows.map(row => [row.date, row.projects, row.updates, row.users, row.sessions, row.loads, row.loadSamples ? Math.round(row.averageLoadMs) : '', row.loadSamples, row.starts, row.crashes].join(',')); + const headings = ['Date', 'Projects uploaded', 'Projects updated', 'Users joined', 'Current sessions created', 'Player loads', '95th percentile load ms', 'Load samples', 'Player starts', 'Crashes']; + const lines = dailyRows.map(row => [row.date, row.projects, row.updates, row.users, row.sessions, row.loads, row.loadSamples ? Math.round(row.p95LoadMs) : '', row.loadSamples, row.starts, row.crashes].join(',')); const url = URL.createObjectURL(new Blob([[headings.join(','), ...lines].join('\n')], {type: 'text/csv'})); const link = document.createElement('a'); link.href = url; @@ -398,8 +398,8 @@ const StatsOverview = ({view}) => { detail={communityText('{value1} of {value2} projects', {value1: num(stats.sharedProjects), value2: num(stats.totalProjects)})} /> { />
{ className={styles.dataHeader} icon={Database} title={communityText('Daily data')} - lead={communityText('Exact values behind the charts. Load averages only use completed loads with a recorded duration.')} + lead={communityText('Exact values behind the charts. Load times only use completed loads with a recorded duration.')} actions={(