ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.48k stars 802 forks source link

Story of the Blanks: Stuck on preloader #9060

Open waspennator opened 1 year ago

waspennator commented 1 year ago

Describe the bug

https://www.newgrounds.com/portal/view/573755?emulate=flash

And the swf itself if it helps make testing any easier. Story-Of-The-Blanks.zip

Tested on NG and desktop, game seems to get stuck on the preloader almost every time on my laptop, sometimes it'll pop up with the play button, sometimes it won't, or I can use the right click play method to get it to go further, but it still gets stuck in the end.

Blanks1

Looking through the logs I see 3 specific errors.

AVM2 error: Object(ErrorObject(ErrorObject(GcCell(Gc { ptr: 0xb8828c }))))

ReferenceError: Error # 1069: Property threshold not found on flash.display.BitmapData and there is no default value.

Error occured when running AVM2 frame script: AvmError(Object(ErrorObject(ErrorObject(GcCell(Gc { ptr: 0xb8828c })))))

Expected behavior

It should look like this and be able to boot up to the title screen

Blanks2

Affected platform

Browser's extension

Operating system

Windows 11

Browser

Edge 108

Additional information

No response

Lord-McSweeney commented 1 year ago

This game needs BitmapData.threshold on AVM2. #8822's implementation of BitmapData.threshold on AVM1 could be ported over to AVM2 to fix this issue.

waspennator commented 1 year ago

Looks like bitmapdata.threshold got merged in for avm1. Maybe it could be looked into for the avm2 side in the future.

waspennator commented 1 year ago

www.newgrounds.com-1678937180254.log

Even with #10055 merged in, it still seems to be randomly inconsistent when the play button shows up or not. But when the play button does show up, it does seem to progress further. On web it gets stuck on a black screen for 10 seconds or so, before a bunch of messages pop up in the log saying that a frame script related to the timer function was terminated because it took too long, before loading to this weird title screen.

On Ruffle: Story of The Blanks Ruffle

How it should look on Desktop ruffle and flash: Story of the Blanks Flash

Game is still unplayable anyways though, cause as soon as you press space, the game turns into a stutter fest as it transitions into the gameplay, even moving applebloom around is a stutterfest.

waspennator commented 1 year ago

Retested again with latest nightly, on desktop I seem to be getting playable performance now, as dialogue and even screen transitions when moving between screens no longer seems to turn the game into a stutterfest anymore on desktop.

On web it also loads before the script times out, meaning the title screen issue is no longer present. However the game does seem to freeze for 2-3 seconds when moving between screens (The title screen to the first screen doesn't count) and seems to freeze entirely once dialogue with twilight starts.

And the game still seems to be 50/50 on when the play button shows up.

waspennator commented 11 months ago

Game still seems to lag with web extension when moving between screens during gameplay and when text boxes pop up, and the play button still seems to be entirely random when it decides to show up.

waspennator commented 3 months ago

Unsure if the loading problem has regressed or stayed the same, but I can't the preloader to function properly at all compared to flash. It always loads up and shows play on there, but on ruffle I have to force it via right click and play, console logs don't show anything helpful.

Otherwise from further testing, it seems like the lag from the text boxes popping up are gone now. The only lag i'm noticing is during screen transitions, here are my observations.

Flash Player: Transitions are near instant, like half a second after you transition from one screen to the next.

Ruffle Desktop: Slower than Flash by like an extra half second. not terrible, but definitely noticeable when running with flash.

Ruffle Web: Seems to struggle more with screen transitions then desktop, sometimes it loads for a second, othertimes it takes a few, the music always cuts out when it occurs.

waspennator commented 3 months ago

Tried running it through a flash decompiler to see whats going on with it, dunno if this has anything to do with why the preloader isn't working on ruffle web or desktop.

public dynamic class MainTimeline extends MovieClip {

  public var Starting:Boolean;

  public var LoadingBarInstance:LoadingBar;

  public var game:Game;

  public var Progress:Number;

  public function MainTimeline()
  {
     super();
     addFrameScript(0,this.frame1,2,this.frame3);
  }

  public function ProgressAction(param1:ProgressEvent) : void
  {
     this.Progress = param1.target.bytesLoaded / param1.target.bytesTotal;
  }

  internal function frame1() : *
  {
     stop();
     this.Progress = 0;
     this.LoadingBarInstance.PlayButton.buttonMode = true;
     this.LoadingBarInstance.PlayButton.visible = false;
     this.LoadingBarInstance.PlayButton.addEventListener(MouseEvent.CLICK,this.StartGame);
     this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,this.ProgressAction);
     this.addEventListener(Event.ENTER_FRAME,this.UpdatePreLoader);
  }

  internal function frame3() : *
  {
     stage.frameRate = 2;
     this.game = new Game(stage);
  }

  public function UpdatePreLoader(param1:Event) : *
  {
     var _loc2_:SoundCartridge = null;
     this.LoadingBarInstance.gotoAndStop(1 + int(this.Progress * 49));
     if(this.Progress >= 1)
     {
        this.LoadingBarInstance.PlayButton.visible = true;
     }
     if(this.Starting)
     {
        this.LoadingBarInstance.y += 20;
        this.LoadingBarInstance.scaleY -= 0.035;
        this.LoadingBarInstance.rotation += 1;
        if(this.LoadingBarInstance.y == 400)
        {
           _loc2_ = new SoundCartridge();
           _loc2_.play();
        }
        if(this.LoadingBarInstance.y > 1200)
        {
           this.removeEventListener(Event.ENTER_FRAME,this.UpdatePreLoader);
           gotoAndStop(3);
        }
     }
  }

  public function StartGame(param1:MouseEvent) : *
  {
     if(this.Progress >= 1)
     {
        this.Starting = true;
     }
  }

} }

Also providing ingame and map scripts on the chance it can help narrow down the remaining lag with screen transitions somehow.

Ingame script.txt Map script.txt

Update: It seems like if I try loading up the game fast enough (Loading up the ruffle instance as soon as the page loads) then the preloader seems more likely to work.