From 9d62dfbd67d07dd6a62f5aeb5c8a1b1d7e3102c8 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Fri, 17 May 2024 01:13:49 +0200 Subject: [PATCH 1/2] core: Fix stop() when executing attachMovie in DoInitAction This fixes a bug where the code in the first frame of a movie clip could have been executed after the second frame (so that instructions like stop did not work properly). That is because when the first frame was executed in preload (e.g. for a sprite attached using attachMovie), the actions were queued, the second frame was executed in run_frame, and then the actions from the first frame were executed. Ensuring that all actions are executed after preload fixes this issue. --- core/src/player.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/player.rs b/core/src/player.rs index f46b88821141..57fe5963e162 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -1657,6 +1657,8 @@ impl Player { did_finish = LoadManager::preload_tick(context, limit); } + Self::run_actions(context); + did_finish }) } From 57c81a4329b68872b89323e2f4c51b4763bf3bf0 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Fri, 17 May 2024 01:14:23 +0200 Subject: [PATCH 2/2] tests: Add attach_movie_stop test This test verifies that stop() works properly for a movie clip attached with attachMovie in DoInitAction. --- .../tests/swfs/avm1/attach_movie_stop/asset_1.as | 3 +++ .../tests/swfs/avm1/attach_movie_stop/asset_2.as | 1 + .../tests/swfs/avm1/attach_movie_stop/output.txt | 3 +++ tests/tests/swfs/avm1/attach_movie_stop/test.as | 2 ++ tests/tests/swfs/avm1/attach_movie_stop/test.swf | Bin 0 -> 219 bytes tests/tests/swfs/avm1/attach_movie_stop/test.toml | 1 + 6 files changed, 10 insertions(+) create mode 100644 tests/tests/swfs/avm1/attach_movie_stop/asset_1.as create mode 100644 tests/tests/swfs/avm1/attach_movie_stop/asset_2.as create mode 100644 tests/tests/swfs/avm1/attach_movie_stop/output.txt create mode 100644 tests/tests/swfs/avm1/attach_movie_stop/test.as create mode 100644 tests/tests/swfs/avm1/attach_movie_stop/test.swf create mode 100644 tests/tests/swfs/avm1/attach_movie_stop/test.toml diff --git a/tests/tests/swfs/avm1/attach_movie_stop/asset_1.as b/tests/tests/swfs/avm1/attach_movie_stop/asset_1.as new file mode 100644 index 000000000000..3b51421ad4f8 --- /dev/null +++ b/tests/tests/swfs/avm1/attach_movie_stop/asset_1.as @@ -0,0 +1,3 @@ +trace("Before stop"); +stop(); +trace("After stop"); diff --git a/tests/tests/swfs/avm1/attach_movie_stop/asset_2.as b/tests/tests/swfs/avm1/attach_movie_stop/asset_2.as new file mode 100644 index 000000000000..1038b8495e07 --- /dev/null +++ b/tests/tests/swfs/avm1/attach_movie_stop/asset_2.as @@ -0,0 +1 @@ +trace("Second frame, I shouldn\'t be executed!"); diff --git a/tests/tests/swfs/avm1/attach_movie_stop/output.txt b/tests/tests/swfs/avm1/attach_movie_stop/output.txt new file mode 100644 index 000000000000..40a5be5c9cab --- /dev/null +++ b/tests/tests/swfs/avm1/attach_movie_stop/output.txt @@ -0,0 +1,3 @@ +Attaching asset +Before stop +After stop diff --git a/tests/tests/swfs/avm1/attach_movie_stop/test.as b/tests/tests/swfs/avm1/attach_movie_stop/test.as new file mode 100644 index 000000000000..bacb80d482a1 --- /dev/null +++ b/tests/tests/swfs/avm1/attach_movie_stop/test.as @@ -0,0 +1,2 @@ +trace("Attaching"); +attachMovie("Test", "test", 30); diff --git a/tests/tests/swfs/avm1/attach_movie_stop/test.swf b/tests/tests/swfs/avm1/attach_movie_stop/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..038490d66809c23556a58dc5eec2c3b74710a74d GIT binary patch literal 219 zcmV<103`oIS5pWX0RRAaoJEc?Zo)tiMZb4J4vi5NqCuO6C=nIZNEm1+sFFT%>~XLJ zUgRARNAL-#bC}!<#>RpvX1+%M&7U*c-$3^d@Dx@(NG;V>s*{QIpzxu~fs6&Ewjkr! z9uTHX#a&($UNG{j;f*lIRG069eNt@m#H2;Er?FWZx3$MzlE1O}Awy@1k4(vHLkkuJ zo={)pICPE}{~aaq*Fb)g>~ew@LgpymX8Es)Y70NiPb{iE8+*#AxqWHFAIg#X!K$fh VqnnMM^(EZbWtHZO1a2sCK5-HfXmkJo literal 0 HcmV?d00001 diff --git a/tests/tests/swfs/avm1/attach_movie_stop/test.toml b/tests/tests/swfs/avm1/attach_movie_stop/test.toml new file mode 100644 index 000000000000..568cadba535f --- /dev/null +++ b/tests/tests/swfs/avm1/attach_movie_stop/test.toml @@ -0,0 +1 @@ +num_ticks = 2