ruffle-rs / ruffle

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

Very slow to load - https://www.4399.com/flash/97801.htm #16490

Open wsxarcher opened 4 months ago

wsxarcher commented 4 months ago

Describe the bug

Stuck during loading

(stack trace seems similar to https://github.com/ruffle-rs/ruffle/issues/16488)

WARN core\src\avm2\globals\flash\display\display_object_container.rs:184 Display object container has no child with name border

Expected behavior

Load the game

Content Location

https://www.4399.com/flash/97801.htm

Affected platform

Browser's extension

Operating system

Window 11

Browser

Edge/Chrome 125

Additional information

This game is part of a bigger effort to support 4399.com games. There might be other issues with this website, from how it handles Flash checks and many CORS issues. Unfortunately, some games cannot be easily debugged on desktop because the swf download other swf or do requests while logged in.

If Ruffle is not detected try to reload the page multiple times because of the known race condition on the Flash check. To avoid refreshing try this Tampermonkey user script 一键下载 flash 游戏 (greasyfork.org)

To solve these issues refers to previous issues such as:

wsxarcher commented 4 months ago

Game does load but it takes some minutes, it's a perf issue. 1.zip

wsxarcher commented 4 months ago
image

A very long time is spent to iterate over the avm2 orphaned objects in run_inner_goto_frame. I tried to skip all the orphans or make Avm2::cleanup_dead_orphans(context); clean also the ones placed_by_actionscript and it loads really fast but then when clicking to play the game some objects by name cannot be found.

2024-05-30T15:50:12.007442Z ERROR ruffle_core::avm2::events: Error dispatching event EventObject(EventObject { type: "click", class: flash.events::MouseEvent, ptr: 0x19b56ac3d30 }) to handler FunctionObject(FunctionObject { ptr: 0x19b5ada9cf0, name: Ok("hud.item::Button/onMouseClick()") }) : TypeError: Error #1009: Cannot access a property or method of a null object reference. (accessing field: getChildByName)
        at iriysoft.ui::ContainerButton()
        at hud.item::Button/initButton()
        at hud.item::Button()
        at gui::GameScreen/constructButton()
        at gui::GameScreen/createButton()
        at gui::ChooseProfileScreen/createSlot()
        at gui::ChooseProfileScreen/initButtonsBlock()
        at gui::GameScreen/initGameScreen()
        at gui::ChooseProfileScreen/initChooseProfileScreen()
        at gui::ChooseProfileScreen()
        at Main/gotoChooseProfileScreen()
        at Main/onActivateTitleScreenButton()
        at Function/apply()
        at iriysoft.core::Signal/dispatch()
        at gui::GameScreen/dispatchButtonIDClick()
        at gui::GameScreen/onButtonClick()
        at Function/apply()
        at iriysoft.core::Signal/dispatch()
        at hud.item::Button/onMouseClick()

So probably those objects are loaded via as3 and wrongly executed multiple times but they need to still be alive by the gc