Skip to content

Commit a9a25a7

Browse files
committed
core: Perform frame script cleanup outside of normal execution
1 parent 7299d27 commit a9a25a7

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

core/src/display_object/movie_clip.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,14 @@ impl<'gc> MovieClip<'gc> {
24992499
}
25002500
}
25012501

2502+
pub fn run_frame_script_cleanup(context: &mut UpdateContext<'gc>) {
2503+
while let Some(clip) = context.frame_script_cleanup_queue.pop_front() {
2504+
clip.0.write(context.gc()).has_pending_script = true;
2505+
clip.0.write(context.gc()).last_queued_script_frame = None;
2506+
clip.run_local_frame_scripts(context);
2507+
}
2508+
}
2509+
25022510
fn run_local_frame_scripts(self, context: &mut UpdateContext<'gc>) {
25032511
let mut write = self.0.write(context.gc());
25042512
let avm2_object = write.object.and_then(|o| o.as_avm2_object());
@@ -2711,23 +2719,13 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
27112719
}
27122720

27132721
fn run_frame_scripts(self, context: &mut UpdateContext<'gc>) {
2714-
let cleans_up = context.frame_script_cleanup_queue.is_empty();
2715-
27162722
self.run_local_frame_scripts(context);
27172723

27182724
if let Some(container) = self.as_container() {
27192725
for child in container.iter_render_list() {
27202726
child.run_frame_scripts(context);
27212727
}
27222728
}
2723-
2724-
if cleans_up {
2725-
while let Some(clip) = context.frame_script_cleanup_queue.pop_front() {
2726-
clip.0.write(context.gc()).has_pending_script = true;
2727-
clip.0.write(context.gc()).last_queued_script_frame = None;
2728-
clip.run_local_frame_scripts(context);
2729-
}
2730-
}
27312729
}
27322730

27332731
fn render_self(&self, context: &mut RenderContext<'_, 'gc>) {

core/src/frame_lifecycle.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub fn run_all_phases_avm2(context: &mut UpdateContext<'_>) {
9494
orphan.run_frame_scripts(context);
9595
});
9696
stage.run_frame_scripts(context);
97+
MovieClip::run_frame_script_cleanup(context);
9798

9899
*context.frame_phase = FramePhase::Exit;
99100
stage.exit_frame(context);

0 commit comments

Comments
 (0)