Behavior of movie clips with incorrect frameCount is wrong
Some SWFs in the wild contain movieclips with a mismatch between their frameCount field and the actual number of frames they contain (see #929). In the Flash Player, these clips will still loop when they hit their End tag, but Ruffle doesn't loop them at this point (waiting for them to hit the specified frameCount).
_totalframes returns frameCount even though their are fewer frames. More research will have to be done to see the behavior of gotos, etc.
Example SWF (hexedited by hand): wrong_framecount.zip
Some quick results I'm seeing about the frameCount field in the header with some hex editing:
- If it's larger than it should be:
- the Adobe player doesn't care, just loops the frames up until the End tag.
- Ruffle will wait for the equivalent time of the "missing" frames to pass before looping back to the beginning.
- If it's smaller than it should be:
- the Adobe player doesn't care, loops all the frames up until the End tag.
- Ruffle doesn't play the existing frames past
frameCount
At least none of them seem to read anything from the file past the first End tag they find (nor does the JPEXS decompiler) - "verified" by randomly mangling a bunch of tag IDs after an End tag in the middle, and not getting any crashes or errors from either player.
EDIT: Actually Ruffle does try to read past the first End tag, if the frameCount is large enough to "index" past it?
However, all of this was done with no Goto* tags, and only on a toplevel movie.
I was about to open an issue about this, then realized it already exists. :-)
So I'm just attaching the samples I made (not sure they will be useful but who knows):
sample.zip (issue is in sprites\DefineSprite (74))
This has been partially fixed by https://github.com/ruffle-rs/ruffle/pull/21526, but that PR still doesn't fix gotoing past the end of the header frame count
This has been partially fixed by #21526, but that PR still doesn't fix gotoing past the end of the header frame count
Actually, I believe it should fix gotoing past the end of the header frame count, and actually one of the tests I added (swf_wrong_frame_count_isplaying) has gotoAndPlay(2) where the header frame count is 1, and it works correctly.
Ah, okay, I thought the logic you used in the PR was adapted from Aaron's PR, which didn't fix the goto case.