-
-
Notifications
You must be signed in to change notification settings - Fork 931
core: Run frames for AVM2 movies loaded into AVM1 #21959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
836d3dc
core: Don't make MovieClips orphans in `set_object2`
Lord-McSweeney bc8d4f5
core: Allow AVM2 movies loaded by AVM1 to run their frames
Lord-McSweeney f728d21
core: Fix getting path of AVM2 DisplayObject loaded by AVM1 code
Lord-McSweeney 68d9350
tests: Add test for loading AVM2 into AVM1
Lord-McSweeney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,8 +187,6 @@ pub struct MovieClipData<'gc> { | |
| attached_audio: Lock<Option<NetStream<'gc>>>, | ||
|
|
||
| /// The next MovieClip in the AVM1 execution list. | ||
| /// | ||
| /// `None` in an AVM2 movie. | ||
| next_avm1_clip: Lock<Option<MovieClip<'gc>>>, | ||
|
|
||
| audio_stream: Cell<Option<SoundInstanceHandle>>, | ||
|
|
@@ -421,8 +419,8 @@ impl<'gc> MovieClip<'gc> { | |
|
|
||
| /// Execute all other timeline actions on this object. | ||
| pub fn run_frame_avm1(self, context: &mut UpdateContext<'gc>) { | ||
| if !self.movie().is_action_script_3() { | ||
| // Run my load/enterFrame clip event. | ||
| // Run my load/enterFrame clip event. | ||
| if !self.movie().is_action_script_3() || !context.root_swf.is_action_script_3() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add a comment here explaining this situation? I.e. why it is being run for an AVM2 movie |
||
| let is_load_frame = !self.0.contains_flag(MovieClipFlags::INITIALIZED); | ||
| if is_load_frame { | ||
| self.event_dispatch(context, ClipEvent::Load); | ||
|
|
@@ -1995,7 +1993,11 @@ impl<'gc> MovieClip<'gc> { | |
| let object = | ||
| Avm2StageObject::for_display_object(context.gc(), display_object, class_object); | ||
|
|
||
| self.set_object2(context, object); | ||
| self.set_object2(context.gc(), object); | ||
|
|
||
| if self.is_avm2_orphan() { | ||
| context.orphan_manager.add_orphan_obj(self.into()); | ||
| } | ||
| } | ||
|
|
||
| /// Construct the AVM2 side of this object. | ||
|
|
@@ -2032,7 +2034,10 @@ impl<'gc> MovieClip<'gc> { | |
| let class_object = context.avm2.classes().avm1movie; | ||
| let object = Avm2StageObject::for_display_object(context.gc(), self.into(), class_object); | ||
|
|
||
| self.set_object2(context, object); | ||
| self.set_object2(context.gc(), object); | ||
|
|
||
| // No need to mark `self` as an orphan, as it's about to be adopted by | ||
| // the AVM2 `Loader` object | ||
| } | ||
|
|
||
| pub fn register_frame_script( | ||
|
|
@@ -2602,7 +2607,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> { | |
|
|
||
| self.set_default_instance_name(context); | ||
|
|
||
| if !self.movie().is_action_script_3() { | ||
| if !self.movie().is_action_script_3() || !context.root_swf.is_action_script_3() { | ||
| context.avm1.add_to_exec_list(context.gc(), self); | ||
|
|
||
| self.construct_as_avm1_object(context, init_object, instantiated_by, run_frame); | ||
|
|
@@ -2617,12 +2622,9 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> { | |
| self.0.object2.get() | ||
| } | ||
|
|
||
| fn set_object2(self, context: &mut UpdateContext<'gc>, to: Avm2StageObject<'gc>) { | ||
| let write = Gc::write(context.gc(), self.0); | ||
| fn set_object2(self, mc: &Mutation<'gc>, to: Avm2StageObject<'gc>) { | ||
| let write = Gc::write(mc, self.0); | ||
| unlock!(write, MovieClipData, object2).set(Some(to)); | ||
| if self.parent().is_none() { | ||
| context.orphan_manager.add_orphan_obj(self.into()); | ||
| } | ||
| } | ||
|
|
||
| fn set_perspective_projection(self, mut perspective_projection: Option<PerspectiveProjection>) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,10 @@ impl<'gc> OrphanManager<'gc> { | |
| pub fn cleanup_dead_orphans(&mut self, mc: &Mutation<'gc>) { | ||
| self.orphans_mut().retain(|d| { | ||
| if let Some(dobj) = valid_orphan(*d, mc) { | ||
| let has_avm1_parent = dobj | ||
| .parent() | ||
| .is_some_and(|p| !p.movie().is_action_script_3()); | ||
|
|
||
| // All clips that become orphaned (have their parent removed, or start out with no parent) | ||
| // get added to the orphan list. However, there's a distinction between clips | ||
| // that are removed from a RemoveObject tag, and clips that are removed from ActionScript. | ||
|
|
@@ -78,14 +82,18 @@ impl<'gc> OrphanManager<'gc> { | |
| // indefinitely (if there are no remaining strong references, they will eventually | ||
| // be garbage collected). | ||
| // | ||
| // To detect this, we check 'placed_by_avm2_script'. This flag get set to 'true' | ||
| // To detect this, we check 'placed_by_script'. This flag get set to 'true' | ||
|
Comment on lines
-81
to
+85
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 2 changes should be reverted |
||
| // for objects constructed from ActionScript, and for objects moved around | ||
| // in the timeline (add/remove child, swap depths) by ActionScript. A | ||
| // RemoveObject tag will only affect objects instantiated by the timeline, | ||
| // which have not been moved in the displaylist by ActionScript. Therefore, | ||
| // any orphan we see that has 'placed_by_avm2_script()' should stay on the orphan | ||
| // any orphan we see that has 'placed_by_script()' should stay on the orphan | ||
| // list, because it was not removed by a RemoveObject tag. | ||
| dobj.placed_by_avm2_script() | ||
| // | ||
| // Also, we consider AVM2 MovieClips loaded into an AVM1 parent to always | ||
| // be orphans, since we know they were placed by AVM1 code and not by | ||
| // the timeline. | ||
| dobj.placed_by_avm2_script() || has_avm1_parent | ||
| } else { | ||
| false | ||
| } | ||
|
|
@@ -109,7 +117,7 @@ fn valid_orphan<'gc>( | |
| mc: &Mutation<'gc>, | ||
| ) -> Option<DisplayObject<'gc>> { | ||
| if let Some(dobj) = dobj.upgrade(mc) { | ||
| if dobj.parent().is_none() { | ||
| if dobj.is_avm2_orphan() { | ||
| return Some(dobj); | ||
| } | ||
| } | ||
|
|
||
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate here when it's
NonevsSome? IIUC it'sSomewhen either this movie clip or the root MC is from AVM1. Because without a comment I'd assume it's for AVM1 only.