Skip to content

avm1: Fix regression with action_get_url_2 and MovieClip without DisplayObject#23288

Draft
evilpie wants to merge 2 commits intoruffle-rs:masterfrom
evilpie:regression-coerce
Draft

avm1: Fix regression with action_get_url_2 and MovieClip without DisplayObject#23288
evilpie wants to merge 2 commits intoruffle-rs:masterfrom
evilpie:regression-coerce

Conversation

@evilpie
Copy link
Copy Markdown
Collaborator

@evilpie evilpie commented Mar 19, 2026

Fixes #22674

This was a regression introduced in #22221.

Before:

if let Value::Object(target) = target_val {
target.as_display_object()
} else if let Value::MovieClip(_) = target_val {
let tgt = target_val.coerce_to_object(self);
tgt.as_display_object()
} else {

After:

if let Some(target) = target_val.as_object(self) {
target.as_display_object()
} else {

The code is subtly different. Before, we used None if the MovieClip didn't have a DisplayObject, but afterwards, we fell through to the else block.

/cc @moulins

@evilpie evilpie added A-avm1 Area: AVM1 (ActionScript 1 & 2) T-fix Type: Bug fix (in something that's supposed to work already) labels Mar 19, 2026
@kjarosh
Copy link
Copy Markdown
Member

kjarosh commented Mar 19, 2026

Having a test would be nice. Otherwise we'll regress it again in the future.

@kjarosh
Copy link
Copy Markdown
Member

kjarosh commented Mar 19, 2026

@evilpie evilpie marked this pull request as draft March 20, 2026 23:24
@evilpie
Copy link
Copy Markdown
Collaborator Author

evilpie commented Mar 21, 2026

While the new behavior did cause the game to break, the new behavior might actual match Flash?

class Test {
    static function main() {
        var mc = _root.createEmptyMovieClip("mc", 1);
        mc.removeMovieClip();
        // This should NOT unload _root.
        loadMovie("", mc);

        // Check after a delay that _root was not unloaded.
        _root.checkId = setInterval(function() {
            clearInterval(_root.checkId);
            trace("_totalframes: " + _root._totalframes);
        }, 200);
    }
}

This logs nothing for me in Flash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm1 Area: AVM1 (ActionScript 1 & 2) T-fix Type: Bug fix (in something that's supposed to work already)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slasher Click 2: The tale of Magawa: Status ailment crash

3 participants