-
-
Notifications
You must be signed in to change notification settings - Fork 881
avm1: Display objects are indirectly referenced by string path (fix #1513) #5492
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
Conversation
AVM1 display objects do not actually hold pointers to their display object, but instead refer to them indirectly via string path (for example, `_level0.clip.foo`). This means: * Every property access on an AVM1 display object requires re-resolving the path to the actual object. * If that display object is removed from the stage, the AVM1 object still exists, but the the path no longer resolves to a display object, so the reference is "dangling". Any operations on the AVM1 object are noops. * If a display object with the same path is later added to the stage, the AVM1 object will once again resolve, and all operations will work using the new display object. Fixes ruffle-rs#993, ruffle-rs#1415, ruffle-rs#1513, ...
d9bf4d3
to
480b3db
Compare
Coercing a display object to string results in the display object's path. `toString` is not used. If the clip has been removed from the stage, the empty string is returned. Remove `avm1::display_object::to_string`. (`MovieClip.toString` is actually Object's `toString` from the prototype chain.)
This should return "object" for non-movieclips, but default to "movieclip" if the display object reference is dangling.
Non-movieclip display objects are not accessible from the AVM in version 5 and earlier SWFs. For example, attempts to resolve to a button will instead resolve to the button's parent. Addresses ruffle-rs#1029.
480b3db
to
7789b57
Compare
Awesome! This also seems to fix #5277 and Hellbound (the character was "stuttering" in the air after losing a life). But there's a regression in Steppenwolf 5-1. The game softlocks when you try to climb the rope. The following messages are logged in the console:
Could this be related to #5502? |
@Herschel, this PR will help to solve at least 22 issues. I mention this, just in case it could be finished and merged. |
Many thanks for your help and your excellent work. |
just some comments that might help to consider finishing this PR.
Many thanks for your excellent work. |
Once #7254 is merged, this should fix a bug in FancyPants2 where the player gets frozen in midair. |
Excuse me for asking this obvious question, this is an important issue in AVM1. Is there any ETA for the merge of this PR? |
This branch doesn't build anymore due to a borrowing issue, so I rebased this up to ~Nov to be able to test with it, see https://github.com/CUB3D/ruffle/tree/avm1-mc-string-ref This also seems to fix #2840 |
@Toad06, does the regression mentioned in #5492 (comment) happen after the merge of #5502? I wonder whether this PR may be merged when it doesn’t break anything. I know that this isn’t ideal, but it will help to fix particular issues after the merge. Happy New Year to everyone! |
Superseded by #9447. |
Proof-of-concept of changing
avm1::StageObject
to reference its display object via string path instead ofGcCell
. This is the last big gotcha to tackle in AVM1, so making a rough draft to gain an understanding of the behavior. Let's hold off on merging this until after #5339.Display objects in AVM1 should not actually hold pointers to their linked display object, but instead refer to it indirectly via absolute string path (for example,
_level0.clip.foo
). See https://moock.org/asdg/technotes/movieclipDatatype for more info.This means:
Every movieclip property access
clip.foo
now requires a full resolve of the path, so this could significantly hurt performance -- measurement is needed.TODO:
onUnload
tests fail because the path no longer resolves.base
fromStageObject
and instead change theDisplayObject::object
into aScriptObject
/PropertyMap
?ScriptObject
from the display object itself.ScriptObject
after dereferencing the path.prototype
,interfaces
etc. work correctly.StageObject::path
could store the parsed path segments instead of full string. Something like{ level: Depth, segments: SmallVec<AvmString> }
.Fixes #993, #1017, #1029, #1114, #1140, #1415, #1513, #3839, #3916, #4404, #4793, #5275, others...