Skip to content
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

AVM2 Queued Tags & Looping Gotos fixes #7570

Merged
merged 47 commits into from
Aug 26, 2022

Conversation

kmeisthax
Copy link
Member

This is a rewrite of much of #5876, minus the SimpleButton 'fixes' from #7015. It also includes the frame lifecycle changes in #7048.

@Herschel suggested I stop scanning the SWF three times, and instead just maintain an internal tag queue on each clip for running each event. Our exact structure is a HashMap with one queue per depth; with code maintaining the invariant that we only allow a PlaceObject, RemoveObject, or remove-then-add pair on each depth. Any other SWF tag structure on a given depth is normalized to one of these three patterns. This is vaguely reminiscent of the GotoPlaceObject queueing system, but we cannot use that type across frame phases as it is not 'static.

I'm far more confident in this design than my prior PR, which was prone to tag-stream desyncs. A large amount of the commits in that PR were purely just to correct for goto happening at inconvenient times between tag stream scans. The other half were to emulate the queue system without using a queue.

@kmeisthax kmeisthax force-pushed the avm2-queuedevents branch 2 times, most recently from 4c07bee to 8a6f1d1 Compare August 17, 2022 23:32
@kmeisthax kmeisthax force-pushed the avm2-queuedevents branch 2 times, most recently from 7605b72 to 787f5ba Compare August 24, 2022 22:15
…clip back and forth to better demonstrate a bug I ran into with frame numbering
The test output for this test is sensitive to where we cut off each frame, because it doesn't stop all of it's handlers at the end of the test. Flash Player will just print lines forever so the end of the test is entirely arbitrary.
kmeisthax and others added 24 commits August 25, 2022 19:52
…ame` into a single method, `catchup_display_object_to_frame`.

The rationale for the catch-up logic is as follows:

 * We must always enter-frame and construct objects, even if those respective display events haven't happened yet.
 * Display objects created in event handlers still need to run catchup phases, otherwise they will tag-stream desync
 * Frame scripts are never triggered by catchup phases
 * `exit_frame` is not a catchup phase as it is *only* an event broadcast currently
…ve actions are queued until later.

This prevents repeated place/remove actions at the same depth from resulting in repeated event dispatches.
They are no longer needed, frame advance happens at enterframe time.
We still retain the queue system as events are fired at removal time, and those events can trigger more gotos. If such a goto happens, AS3 code will hit a clip still in the old state rather than an inconsistent one. I don't have test coverage for this exact scenario just yet.
…lip, even if we already executed that script beforehand.
This is in keeping with the whole idea of a "recursive frame": gotos run the entire frame lifecycle on the target clip, including broadcasts for `frameConstructed` and `exitFrame`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants