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

Super Mario 63: problems when entering the castle #6906

Closed
n0samu opened this issue May 7, 2022 · 25 comments · Fixed by #10330
Closed

Super Mario 63: problems when entering the castle #6906

n0samu opened this issue May 7, 2022 · 25 comments · Fixed by #10330
Assignees
Labels
avm1 AVM1 (ActionScript 1.0 and 2.0) issues bug Something isn't working hitTest Issues involving mouse picking and hitTest performance

Comments

@n0samu
Copy link
Member

n0samu commented May 7, 2022

Describe the bug

To reproduce the bugs:

  1. Load the SWF file with Ruffle
  2. Play through the tutorial (takes 10-20 minutes or so) and reach the castle. Press the up arrow to enter the castle

You should notice these problems:

  • The transition to the next level is extremely slow (takes 1-2 minutes even on high-end hardware)
  • During this transition, memory usage climbs significantly (in my testing, up to 4GB)
  • Once the level starts, many of the objects in the level are missing and part of the background is black/blank

It's still possible to reach the next door. But if you go through that door, there will be another extremely slow transition, and then Mario will end up floating in the sky and unable to move (see screenshot below)
image

Expected behavior

None of these problems should occur.

Affected platform

Browser's extension

Operating system

Windows 10

Browser

Firefox 100

Additional information

I've attached the log from my browser console (log level: info) below, but it may not be very helpful
sm63.log

@n0samu n0samu added the bug Something isn't working label May 7, 2022
@Toad06
Copy link
Member

Toad06 commented May 18, 2022

The Newgrounds version also has this issue. I'm mentioning this because you can skip cutscenes in this version which is nice when testing.

I tried to investigate the issue. When you enter the castle, the following function runs:

_root.StartInsideofCastle = function()
{
   _root.RemoveCourse();
   _root.gotoAndStop("Courseframe");
   _root.StartChar("C-1",0,0,0,0,100,_root.CurrentPlayer,_root.Fluddpow,"StarIn",true);
   _root.onEnterFrame = function()
   {
      _root.CharCode();
   };
};

Removing the _root.onEnterFrame fixes the crash (Mario enters the castle... then keyboard inputs are no longer registered - this is consistent with Flash Player).

However... the same _root.onEnterFrame / _root.CharChode calls also exist in the tutorial level, with no issue at all.

So I think the issue comes from _root.RemoveCourse() which sets _root.onEnterFrame to null and also calls removeMovieClip() a bunch of times. Because of #3839, I believe that this later causes issues in _root.CharCode().

It will be worth testing the game again when #5492 is no longer a draft (the game doesn't work at all currently).

@Toad06 Toad06 added the avm1 AVM1 (ActionScript 1.0 and 2.0) issues label May 18, 2022
@Myzel394
Copy link

Is there a current workaround? @Toad06 how do you remove _root.onEnterFrame? When I download the file and try to edit it, it seems like it contains only minified code.

@n0samu
Copy link
Member Author

n0samu commented Jul 13, 2022

If you just want to play the game, you can download the SWF file and run it using the standalone Flash projector: https://web.archive.org/web/20220331041116/https://www.adobe.com/support/flashplayer/debug_downloads.html
From what Toad stated, it doesn't sound like removing that piece of code would really make the game playable in Ruffle, anyway.

@Scott-Steinheiser
Copy link

Scott-Steinheiser commented Aug 20, 2022

It does not take me 1-2 minutes. It never lets me enter the castle. It is still not working even though I already downloaded the Adobe Flash Projector.

@n0samu
Copy link
Member Author

n0samu commented Aug 21, 2022

It is still not working even though I already downloaded the Adobe Flash Projector.

You need to download the SWF file and open it with the Flash projector. You can download the SWF file from Archive.org.

@Luigi-Fan
Copy link

Where do I download Adobe Flash Projector?
I play on chromebook by the way, so I use Chrome OS.

@Luigi-Fan
Copy link

And, of course, I use Google Chrome.

@Myzel394
Copy link

Myzel394 commented Sep 2, 2022

@Luigi-Fan not sure if that's possible on ChromeOS, but I ended up using a Windows 11 on a virtual machine and downloaded the exe. It ran perfectly that way

@SamirTheHuman
Copy link

This is what happened in the older versions before Ruffle became a little more advanced. After, it just becomes a big mess. Did not see this post so thanks for showing me this.

@n0samu
Copy link
Member Author

n0samu commented Feb 21, 2023

As noted by others already, Ruffle now times out the script so it doesn't have a chance to complete at all anymore. So when trying to enter the castle, Ruffle freezes for a bit and then cycles through the graphics without running any more ActionScript.

@Adamillo
Copy link

So do we extend the time it takes before the script gets timed out or is there a better solution out there?

@Myzel394
Copy link

@Adamillo if you want to play the game, you could also try setting up a virtual machine with Windows and run the game inside it. This worked for me at least

@Adamillo
Copy link

Adamillo commented Mar 18, 2023

Sure, but at that point why bother when I can can just run the standalone Flash version? Not trying to be mean of course but it's not a good solution when you need this amount of hoops you have to jump through just to play this game on Ruffle

@Myzel394
Copy link

Does the standalone version work with the castle? I haven't played this game in the last time but afaik it didn't work for me

@n0samu
Copy link
Member Author

n0samu commented Mar 18, 2023

You don't need Windows to run the standalone Flash Player. It is also available for Linux and MacOS.

So do we extend the time it takes before the script gets timed out or is there a better solution out there?

Yes, I'm planning to test the game with the script execution limit increased when I get a chance. Right now the limit is only customizable in selfhosted web builds of Ruffle, which makes it a bit difficult. The option is called maxExecutionDuration: https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle#list-of-options

@io12
Copy link

io12 commented Mar 18, 2023

I tested disabling the script execution limit (by modifying the Ruffle code) and when entering the castle, the screen stays black, but RAM usage keeps increasing, which seems like a memory leak.

@io12
Copy link

io12 commented Mar 18, 2023

I could be wrong, but I think this is the infinite loop (in UnpausedCharEngine()).

while(_root.Course.Platforms.hitTest(_X * _root.coursescale / 100 + _root.Course._x,(_Y - 3) * _root.coursescale / 100 + _root.Course._y,true) && !(Squish == true && (_yscale < 70 || attack == true && attackFrame == "Squish")) && (!_root.Course.Platforms.invisground.hitTest(_X * _root.coursescale / 100 + _root.Course._x,(_Y - 3) * _root.coursescale / 100 + _root.Course._y,true) || _root.Invisible !== true) || _root.Course.BPlatforms.hitTest(_X * _root.coursescale / 100 + _root.Course._x,(_Y - 3) * _root.coursescale / 100 + _root.Course._y,true) && yspeed >= -3)
{
   _Y--;
   if(!(attack == true && attackFrame == "Dive"))
   {
      xspeed *= 0.98;
   }
   else
   {
      xspeed *= 0.997;
   }
   _root.FallSquish();
   yspeed = Math.min(0,yspeed);
}

@io12
Copy link

io12 commented Mar 19, 2023

This patch allows entering the castle with key input continuing to work. A zero matrix is appearing somewhere and I think that's breaking the collision check between the castle platforms and the player, causing the infinite loop. I'm not making this a PR though because I'm not sure why the matrix is zero. There may be a deeper issue?

diff --git a/core/src/display_object.rs b/core/src/display_object.rs
index 47d67a3..8a9d618 100644
--- a/core/src/display_object.rs
+++ b/core/src/display_object.rs
@@ -771,7 +771,14 @@ pub trait TDisplayObject<'gc>:
             if let Some(rect) = display_object.scroll_rect() {
                 matrix = Matrix::translate(-rect.x_min, -rect.y_min) * matrix;
             }
-            matrix = *display_object.base().matrix() * matrix;
+            let s = *display_object.base().matrix();
+            let s = if s.a == 0.0 && s.b == 0.0 && s.c == 0.0 && s.d == 0.0 {
+                Matrix::IDENTITY
+            } else {
+                s
+            };
+            matrix = s * matrix;
             node = display_object.parent();
         }
         matrix

@n0samu
Copy link
Member Author

n0samu commented Mar 19, 2023

Thank you for looking into this! I wish I could help - hopefully someone can!

@Herschel
Copy link
Member

Haven't investigated yet, but it's possible that we simply need to handle a zeroed-matrix (which could otherwise be valid) in hitTest and always return false. I'll dig into it a bit!

@Herschel
Copy link
Member

Herschel commented Mar 20, 2023

Yeah, hitTest on a zero-scale object returns false in FP, but true in Ruffle:
hittest-microscopic.zip
Haven't tested to see if this is the issue in Super Mario 63, but I suspect it is.

Is anyone familiar with the game able to hack the SWF so that the game starts at the problematic section? Otherwise I can try some this week.

@Toad06
Copy link
Member

Toad06 commented Mar 22, 2023

@Herschel, here's an edited version.
mm63.zip

@szefkaf
Copy link

szefkaf commented Mar 22, 2023

Hi, I've fixed castle level manually (see attachment) changing C1-Platform' background with new .svg file. In original version background in Castle level is made from few open images, perhaps somewhere path is open and treated as a zero-scale object. So will You fix it in Ruffle or we have to change all levels backgrounds' that causing errors:)?
mm63_castle_fixed.zip

@Adamillo
Copy link

Of course it'll get fixed eventually. Just have to be patient for now

@Herschel Herschel self-assigned this Mar 23, 2023
@n0samu n0samu added the hitTest Issues involving mouse picking and hitTest label Mar 26, 2023
@szefkaf
Copy link

szefkaf commented Mar 30, 2023

Hello,
I've fixed this game under Ruffle, is playable to the end. If someone wants check what was incompatible with Ruffle:
https://grywacz.pl/game/super-mario-63-emu
Most of the errors occurred when Ruffle calling changecourse(); function. So HitTest may be not enough to fix this game without interfering with the source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
avm1 AVM1 (ActionScript 1.0 and 2.0) issues bug Something isn't working hitTest Issues involving mouse picking and hitTest performance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants