Skip to content

Commit a4258b8

Browse files
committed
core: Perform frame script cleanup outside of normal execution
1 parent 3b1cac3 commit a4258b8

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
@@ -2492,6 +2492,14 @@ impl<'gc> MovieClip<'gc> {
24922492
}
24932493
}
24942494

2495+
pub fn run_frame_script_cleanup(context: &mut UpdateContext<'gc>) {
2496+
while let Some(clip) = context.frame_script_cleanup_queue.pop_front() {
2497+
clip.0.write(context.gc()).has_pending_script = true;
2498+
clip.0.write(context.gc()).last_queued_script_frame = None;
2499+
clip.run_local_frame_scripts(context);
2500+
}
2501+
}
2502+
24952503
fn run_local_frame_scripts(self, context: &mut UpdateContext<'gc>) {
24962504
let mut write = self.0.write(context.gc());
24972505
let avm2_object = write.object.and_then(|o| o.as_avm2_object());
@@ -2712,23 +2720,13 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
27122720
}
27132721

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

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

27342732
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)