Commit Graph
5466 Commits
Author SHA1 Message Date
GarboMuffin 326af1930f Clean up unsandboxed extension loader
Remove a bit of global state hackery and prevent concurrent loads
2022-10-22 16:03:05 -05:00
GarboMuffin 1b226fc515 Reject invalid custom extension URLs 2022-10-22 11:05:33 -05:00
GarboMuffin 8fa75e2a3d Remove code duplication in loadExtensionURL 2022-10-22 11:02:42 -05:00
GarboMuffin e78b9b9dc3 Add disabled-by-default unsandboxed extension mode 2022-10-22 00:38:37 -05:00
GarboMuffin 3d75f4759a Fix incorrect mouse position when clientX or clientY is 0
https://github.com/TurboWarp/packager/issues/494
2022-10-21 22:10:22 -05:00
GarboMuffin ab6d10f929 Remove tw-experimental-audio-optimizations
This now lives in TurboWarp/scratch-audio
2022-09-17 18:53:19 -05:00
GarboMuffin 46f6d89b8d Import another test from https://github.com/forkphorus/forkphorus/pull/515 2022-08-28 12:58:33 -05:00
GarboMuffin d8984c80a2 Ignore error in performance.measure() if browser garbage collects a mark 2022-08-27 22:20:42 -05:00
GarboMuffin 4943602646 Import some tests from https://github.com/forkphorus/forkphorus/pull/515 2022-08-27 17:53:30 -05:00
GarboMuffin 135fa04259 Fix tangent of perfect multiplies of 90
Previously they would return very large or very small numbers when they should instead be returning Infinity or -Infinity
2022-08-27 17:49:42 -05:00
GarboMuffin eb600cfcf8 Replace local extended JSON parser with @turbowarp/json 2022-08-14 19:45:30 -05:00
GarboMuffin 106a1daa1f Remove loadProject ExtendedJSON hack
We now do this in scratch-parser instead.
Moving it to scratch-parser allows the alternative parser to run on
projects loaded from compressed files in addition to JSON projects
2022-08-14 19:39:57 -05:00
GarboMuffin 857e2696f5 Update scratch-parser
https://github.com/TurboWarp/scratch-parser/commit/72f2cde00fc968ce40282e0392d3553963730748
2022-08-14 19:35:58 -05:00
GarboMuffin dc9b3f6055 Fix error in uint8ArrayToBase64 when input is too large 2022-08-13 14:45:33 -05:00
GarboMuffin b2e042fde6 Add tests to util_base64.js 2022-08-13 14:40:21 -05:00
GarboMuffin 6db9599f2e Do not use md5 to generate asset IDs in packaged runtime mode
md5 unnecessary in this mode and slows project load by ~10%.
2022-08-05 00:18:09 -05:00
GarboMuffin 1bfc83e666 Use storage.createAsset instead of new storage.Asset in tests 2022-08-05 00:17:53 -05:00
GarboMuffin 9815a27470 Remove references to original asset in packaged runtime mode 2022-08-05 00:17:53 -05:00
GarboMuffin b78dc53c8e Set runtime.isPackaged=true when convertToPackagedRuntime is called 2022-08-05 00:17:47 -05:00
GarboMuffin 9045311a98 Revert "Fix custom extension inputs with default value "" being converted to undefined"
This reverts commit 3afb16c831.
2022-08-02 13:05:17 -05:00
GarboMuffin 3cf6320e9b Revert "Fix tests now that we always emit field default value"
This reverts commit 4325486bef.
2022-08-02 13:05:15 -05:00
GarboMuffin 73c0261480 Test that the center given to the renderer is what's stored in the SVG 2022-08-02 00:06:43 -05:00
GarboMuffin 458b9b7aad Allow rotation center preservation in exported SVGs
Requires additional changes in scratch-gui
2022-08-01 23:50:50 -05:00
GarboMuffin 45a4ca767a Handle weird edge case when createImageBitmap returns undefined
This should already be prevented, but in case it happens anyways, handle the error.
2022-07-31 15:59:20 -05:00
GarboMuffin 20258b5a7d Limit number of concurrent createImageBitmap calls
Browsers, especially Chrome, crumble when we try to create too many
image bitmaps at once. So we'll queue them up when too many are
happening. Projects will load slightly slower but this is still much
faster than <img> with data: URIs
2022-07-31 14:06:51 -05:00
GarboMuffin 125f20b9ce Revert "Don't use createImageBitmap to load bitmap costumes"
Reverts 7abbcdbb10

I am unable to reproduce the claim that ImageBitmap uses more memory
than <img>. Instead I've observed the following:

<img> uses a base64 data: URI which is slower than creating a Blob
directly from the binary data. I also experimented using a blob: URI
with <img> and did find it to perform better. A future commit may use
this when createImageBitmap() is not available.

<img> can't be reliably decoded in parallel. Chrome in particular will
very often wait until texImage2d() to actually decode the image, which
turns image decoding into a single-threaded process. Calling decode()
does not affect this. createImageBitmap is reliably parallelized.

<img>'s only benefit is that projects with a lot of copies of the same
exact costume will usually have their image decoding happen only once
whereas createImageBitmap() will decode each one individually (does not
apply when using blob: URIs).

Chrome:
<img> with data:    48.5MB  4160ms
<img> with blob:    48.4MB  2162ms
createImageBitmap() 48.4MB  1261ms
Equivalent SVGs     60.8MB  3857ms

Firefox:
<img> with data:    88.3MB  3704ms
<img> with blob:    88.9MB  2459ms
createImageBitmap() 92.5MB  2380ms
Equivalent SVGs     483.3MB 5429ms

Using a test project with 100 480x360 unique costumes.
Equivalent SVGs is the same project with each costume converted to SVG,
just for curiosity. Note that SVGs may not actually be rendered or
decoded until the project starts.
2022-07-31 01:51:23 -05:00
GarboMuffin 4325486bef Fix tests now that we always emit field default value 2022-07-27 17:01:36 -05:00
GarboMuffin 21eff9a311 Remove autoplay restriction from iframe extension worker feature policy
Regardless of this, the browser is not guaranteed to actually let the page play audio
We just won't add our own restriction on top of the browser's
2022-07-27 16:10:52 -05:00
GarboMuffin 3afb16c831 Fix custom extension inputs with default value "" being converted to undefined 2022-07-27 16:09:39 -05:00
GarboMuffin 7ea25cbbe8 Fix turbo mode stored in project not appearing in GUI state 2022-07-18 16:34:35 -05:00
Thomas Weber bbd9631a41 Only call renderer.markSkinAsPrivate if it exists 2022-07-13 23:47:03 -05:00
Thomas Weber 2257f975f8 Remove explicit allow from iframe worker feature policy
Feature policy is allow by default.
2022-07-12 01:22:19 -05:00
Thomas Weber 91afd10407 scratchx: Use block color like ScratchX 2022-07-09 19:19:55 -05:00
Thomas Weber 40a9ae057d scratchx: Force upgrade all $.ajax URLs to HTTPS 2022-07-09 19:07:05 -05:00
Thomas Weber 24bdd21bdd Disable test that relies on currentStepTime defaulting to null 2022-07-09 16:41:22 -05:00
Thomas Weber 09df19b60b Add test for edge activated hat returning promise
Adds test for bug fixed in
3062334108
2022-07-09 16:32:28 -05:00
Thomas Weber c4fa4a84a8 Set Runtime.currentStepTime to a number by default instead of null 2022-07-09 16:28:28 -05:00
Thomas Weber 3062334108 Fix edge-activated hats that return promises
This fixes a Scratch bug affecting custom extensions.
There were two bugs in the interpreter:
 - Thread status wouldn't reset after promise resolves
 - Loop finding logic broke on hats and mangled the stack
2022-07-09 02:19:22 -05:00
Thomas Weber 7cbfab1273 Don't use ScratchX block in unknown-opcode-as-reporter-block test
We now support ScratchX blocks, so the test now fails as it assumes we don't.
The test was modified to use a different invalid opcode that isn't a ScratchX block.
2022-07-08 22:35:58 -05:00
Thomas Weber 25e81a4f67 Allow importing simple ScratchX (.sbx) project files
Extends .sb2 importer to convert extension blocks from ScratchX project files
(.sbx) to the format we require.
This doesn't automatically load extensions; they still must be loaded manually.
2022-07-08 22:24:33 -05:00
Thomas Weber 95f57eaf96 scratchx: Extract some functions to separate module 2022-07-08 20:03:03 -05:00
Thomas Weber b182b0afd0 scratchx: Add test for block type ' ' being equivalent to '' 2022-07-08 02:24:55 -05:00
Thomas Weber 651b72f677 scratchx: Add displayName support 2022-07-08 02:22:56 -05:00
Thomas Weber a595b83798 scratchx: Add more to ScratchExtensions.getStatus 2022-07-08 02:20:25 -05:00
Thomas Weber d79cde6047 scratchx: Extract argument index -> id conversion to function 2022-07-08 01:41:49 -05:00
Thomas Weber 3a0cfeae82 scratchx: Implement $.ajax with dataType=script 2022-07-08 01:27:12 -05:00
Thomas Weber 8e0a940231 scratchx: Add stubs for $.getScript, $.ajax, ScratchExtensions.getStatus
Fixes extensions:
https://ericrosenbaum.github.io/tone-synth-extension/tone-synth.js
http://khanning.github.io/scratch-isstracker-extension/iss_extension.js
http://khanning.github.io/scratch-weather-extension/weather_extension.js
https://ericrosenbaum.github.io/spotify-extension/extension.js
2022-07-08 01:21:18 -05:00
Thomas Weber 274cf02d47 scratchx: Fix default value of default argument values 2022-07-07 17:47:55 -05:00
Thomas Weber 3a7e75930a scratchx: Use shorter prefix for generated extension IDs
No projects use this yet so it's safe to change.
2022-07-07 17:47:55 -05:00
Thomas Weber 64ae031026 Don't reference HTMLCanvasElement; breaks tests 2022-07-07 17:47:55 -05:00