ruffle-rs / ruffle

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

Regression in buttons #18610

Open 123jjck opened 3 hours ago

123jjck commented 3 hours ago

Describe the bug

  1. Enter the game: https://xarium.cc/playtest.php
  2. Try to hover and click any of these objects: Image Image
  3. Nothing happens

Expected behavior

Buttons respond to pointing and pressing: Image

Content Location

https://xarium.cc/playtest.php

Affected platform

Self-hosted version

Operating system

Windows 11

Browser

Google Chrome 131.0.6778.70

Additional information

Probably due to #18434 - nightly-2024-11-03 works fine, but starting with nightly-2024-11-05 there are problems

kjarosh commented 3 hours ago

CC @Toad06

Toad06 commented 16 minutes ago

This game loads internal SWFs. One of the files contains the following code:

this.onRollOver = function() {
   mco.gotoAndStop("over_fr");
   ShowHint(this_mc);
};
this.onRollOut = this.onReleaseOutside = function() {
   mco.gotoAndStop("out_fr");
   RemoveHint();
};

If you open the file directly in Flash Player or Ruffle, this won't work because this refers to the root. For the same reason, this issue also occurs if you load it into a different level using loadMovieNum.

However, loading the file into a target movie clip that is part of the root works in Flash Player:

this.createEmptyMovieClip("container", this.getNextHighestDepth());
loadMovie("child.swf", "container");

This doesn't work in Ruffle because fn is_root returns true in this situation, as this function actually indicates "whether this display object represents the root of loaded content".

So replacing the is_root check with DisplayObject::ptr_eq(self.as_displayobject(), self.avm1_root_no_lock()) prevents the issue from occurring.

test.zip