ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

First Frame Bug on Timer

Open molleindustria opened this issue 5 years ago • 5 comments

Hello everybody, thank you for the great work!

I'm encountering a game breaking bug that I was able to reproduce.

Given a movieclip "clippy" and an interval that calls a gotoAndPlay(1) on it every x seconds as shown in the as2 code below:

clippy.onEnterFrame = function()
{ 
	trace(this._currentframe);
	
	if(this._currentframe==1)
	{
	trace("this doesn't fire");
	}

}


myInterval = setInterval(intervalFunction, 2000);

function intervalFunction ()
{
	clippy.gotoAndPlay(1);
}

In the Ruffle emulation, at the interval the first onEnterFrame event is skipped and the condition is never true, even though the first frame is visualized.

The correct Flash behavior would be to fire onEnterFrame on all frames. I'm guessing it has something to do with the interval functions being called after the onEnterFrame events.

Due to common -and awful- programming patterns in Flash, ie putting code in the first frame of a movieclip, this inconsistency can have a major impact on the application logic.

I wish I could help directly but Rust is still a mystery to me.

Attaching an example .fla and .swf firstFrameBug.zip

molleindustria avatar Nov 25 '20 17:11 molleindustria

Thank you so much for the detailed report & a test case!

Dinnerbone avatar Nov 25 '20 17:11 Dinnerbone

*The original swf wasn't correct, I have updated the zip

molleindustria avatar Nov 25 '20 19:11 molleindustria

Any updates on this bug? I'm receiving daily messages of people trying to play one of my games and getting stuck due to this frame skip.

*I don't even have an emulated version of the game on my site, the complains are coming from people who play it on old flash portals (beyond my control) which now run on ruffle.

molleindustria avatar Jul 15 '21 13:07 molleindustria

Just posting the actual onEnterFrame function from the SWF since I was a bit confused at first:

clippy.onEnterFrame = function()
{
   trace(this._currentframe);
   if(this._currentframe == 1)
   {
      message._visible = true;
   }
   else
   {
      message._visible = false;
   }
};

The problems observed in Ruffle are:

  • 1 is never traced (it goes straight from 20 to 2)
  • The green text that says "FIRST FRAME" is never visible

n0samu avatar Sep 13 '22 21:09 n0samu

I think https://github.com/ruffle-rs/ruffle/issues/6144 could be related?

torokati44 avatar Sep 13 '22 21:09 torokati44