ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

Behavior of movie clips with incorrect frameCount is wrong

Open Herschel opened this issue 5 years ago • 2 comments

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

Herschel avatar Jul 25 '20 02:07 Herschel

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.

torokati44 avatar Jan 21 '21 01:01 torokati44

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

Toad06 avatar Oct 27 '22 18:10 Toad06

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

Lord-McSweeney avatar Sep 08 '25 03:09 Lord-McSweeney

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.

Bale001 avatar Sep 08 '25 03:09 Bale001

Ah, okay, I thought the logic you used in the PR was adapted from Aaron's PR, which didn't fix the goto case.

Lord-McSweeney avatar Sep 08 '25 04:09 Lord-McSweeney