Skip to content

avm2: Prevent mouse picking from targeting a loader's root object #20047

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

Merged
merged 6 commits into from
May 9, 2025

Conversation

ZingBallyhoo
Copy link
Contributor

Modifies the logic added in #16334 to also consider the case where the root object of a loader is no longer in the loader's hierarchy. This is common when using Event.COMPLETE + event.target.content instead of adding the loader itself as a child.

@ZingBallyhoo ZingBallyhoo force-pushed the root-mouse-pick branch 3 times, most recently from b075ec6 to 72fbe90 Compare April 8, 2025 16:20
@ZingBallyhoo
Copy link
Contributor Author

The new logic also makes stage.mouseChildren = false work so I added a test for it as a bonus.

@Lord-McSweeney Lord-McSweeney added A-avm2 Area: AVM2 (ActionScript 3) hitTest Issues involving mouse picking and hitTest T-compat Type: Compatibility with Flash Player labels Apr 11, 2025
@ZingBallyhoo
Copy link
Contributor Author

ZingBallyhoo commented May 8, 2025

cc @adrian17

From discord,

// The caller does not expect the stage to be the target, instead return
// None.

For context, there is a lot of code in handle_input_event that interprets None to mean the stage is the pick/hover target.

context.stage.as_interactive()

new_over_object.unwrap_or_else(|| context.stage.into()),

events.push((context.stage.into(), event));

events.push((context.stage.into(), event));

events.push((context.stage.into(), event));

events.push((context.stage.into(), event));

Maybe it would be fine to treat the stage more like a regular object in handle_input_event and let it flow into context.mouse_data.hovered etc but I am not equipped to determine if that could be correct :). So at least for now run_mouse_pick is set up to fiddle with the result to keep the calling logic the same.

The use of combine_with_parent(context.stage.into()) here now instead of the previous custom logic allows the is_root detection to be shared + make stage.mouseChildren = false work now too.

The only cases the stage->None logic runs is:
mouse is over root object - root objects can never be picked -> shared combine logic gives stage as the target
OR
mouse is over child of the stage - stage.mouseChildren = false -> shared combine logic gives stage as the target
both cases are from this one line of code

Copy link
Collaborator

@adrian17 adrian17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just sent some minor code-style notes.

@adrian17 adrian17 force-pushed the root-mouse-pick branch from 8946606 to 86d353e Compare May 9, 2025 20:06
@adrian17 adrian17 force-pushed the root-mouse-pick branch from 86d353e to a683c78 Compare May 9, 2025 21:23
@adrian17 adrian17 merged commit ab6aa2a into ruffle-rs:master May 9, 2025
22 checks passed
@adrian17
Copy link
Collaborator

adrian17 commented May 9, 2025

Thank you!

Hancock33 added a commit to Hancock33/batocera.piboy that referenced this pull request May 11, 2025
------------------------------------------------------------------------------------------
dolphin-emu.mk 0351fd56b1bac5663502282a610aba79f04130d6 # Version: Commits on May 09, 2025
------------------------------------------------------------------------------------------
Merge pull request #10766 from xperia64/dsp_format_fun

DSP accelerator improvements,

---------------------------------------------------------------
ruffle.mk nightly-2025-05-10 # Version: Commits on May 10, 2025
---------------------------------------------------------------
## What's Changed

* chore: Remove approximations from some tests by @kjarosh in ruffle-rs/ruffle#20375

* core: Get rid of GcCell in EditText by @kjarosh in ruffle-rs/ruffle#20365

* avm2: Fix stub imports by @kjarosh in ruffle-rs/ruffle#20373

* chore: Add basic .editorconfig by @kjarosh in ruffle-rs/ruffle#20377

* chore: Update translations by @RuffleBuild in ruffle-rs/ruffle#20384

* avm2: Prevent mouse picking from targeting a loader's root object by @ZingBallyhoo in ruffle-rs/ruffle#20047

## New Contributors

* @ZingBallyhoo made their first contribution in ruffle-rs/ruffle#20047

**Full Changelog**: ruffle-rs/ruffle@nightly-2025-05-09...nightly-2025-05-10,

--------------------------------------------------------------------------------------
scummvm.mk f52ce6cf331d95f4f837f5fce5e8a46b4def335a # Version: Commits on May 09, 2025
--------------------------------------------------------------------------------------
RELEASE: This is 2.9.2pre,

--------------------------------------------------------------------------------------
shadps4.mk 6477dc4f1e699981919022ac69fef59813a9ad94 # Version: Commits on May 09, 2025
--------------------------------------------------------------------------------------
Core: Memory Fixes (#2872)

* Fix VirtualQuery behavior on low addresses.

* Fix VirtualQuery struct

Somewhere in our BitField and array use, the size of our VirtualQuery struct became larger than the struct used on real hardware.

Fixing this fixes some data corruption visible in the name parameter during my tests.

* Default name to anon

On real hardware, nameless mappings are given the name \anon:address\ where address appears to be the address that made the memory call.

For simplicity sake, I'll stick to the name \anon\ for now.

* Place an upper bound on returns from SearchFree

Right now, this upper bound is set based on the limitations of our GPU buffer cache and page table.

Someone with more experience in that area of code should probably fix that at some point.

* More anons

* Clang

* Fix name in sceKernelMapNamedDirectMemory

* strncpy instead of strcpy

Hardcoded the constant size for now, I need to review how real hardware behaves here to determine if anything else is necessary for this to be accurate.

* Fix name behavior

All memory naming functions restrict the name size to a 31 character limit, and return `ORBIS_KERNEL_ERROR_ENAMETOOLONG` if that limit is exceeded.

Since this value is constant for all functions involving names, I've defined it as a constant in kernel's memory.h, and used that in place of any hardcoded 32 character limits.

* Error logging

Hopefully this helps in catching the UFC regression?

* Increase address space upper bound

Probably needs heavy testing, especially on Mac/Windows.

This increases the address space, as needed to accommodate strange memory behaviors seen in UFC.

* VirtualQuery fix

Due to limitations of certain platforms, we initialize our vma_map with 3 separate free mappings.

As such, we need to use a while loop here to accurately query mappings with high addresses

* Fix mappings to high addresses

The PS4's GPU can only handle 40bit addresses. Our texture cache and buffer cache were designed around these limits, and mapping to higher addresses would cause segmentation faults and access violations.

To fix these crashes, only map to the GPU if the mapping is fully contained within the address space the GPU should access.

I'm open to suggestions on how to make this cleaner

* Revert \Increase address space upper bound\

This reverts commit 3d50eeeebb6aa40e38d6f87e6480235c917843f3.

* Revert VirtualQuery while loop

Windows wasn't happy with this, again.

Will try to debug and properly fix this when I have a good chance.

* Fix asserts

FindVMA, due to the way it's programmed, never actually returns vma_map.end(), the furthest it ever returns is the last valid memory area. All those asserts we involving vma_map.end() never actually trigger due to this.

This commit removes redundant asserts, adds messages to asserts that were lacking them, and fixes all asserts designed to detect out of bounds memory accesses so they actually trigger.

I've also fixed some potential memory safety issues.

* Proper error behavior in QueryProtection

Might as well handle this properly while I'm here.

* Clang

* More information about ReserveVirtualRange results

Should help debug issues like the one in The Order: 1886 (CUSA00076)

* Fix assert message

* Update assert message

Extra space

* Fix my bug

Oh hey, finally something that's my fault.

* Fix rasterizer unmaps

Should use adjusted_size here, otherwise we could unmap too much.

Thanks to diegolix29 for spotting this.

* Fix edge case in MapMemory

Code comments explain everything.

This should fix some memory asserts.

* Fix fix

Avoid running the code path if it's unnecessary, since there are many additional edge cases to handle when the VMA map is small.

* Fix fix fix

Should prevent infinite loops, haven't tested properly yet though.

* Split logging for inputs and out_addr in ReserveVirtualRange

Addresses review comments.,

---------------------------------------------------------------------------------------
thextech.mk 8fa74fde5fed0eb8f7f88589193788513684cb31 # Version: Commits on May 10, 2025
---------------------------------------------------------------------------------------
controls.cpp: ouch, fix SharedPauseForce handling (#974),

-------------------------------------------------
ecm.mk v6.14.0 # Version: Commits on Apr 10, 2025
-------------------------------------------------
Update dependency version to 6.14.0,

------------------------------------------------------------------------------------------
devilutionx.mk d024381e5200c60855f82e42753364ea5c018296 # Version: Commits on May 09, 2025
------------------------------------------------------------------------------------------
Use paths::GetBasePath() so it can be freed,

---------------------------------------------------
nblood.mk r14229 # Version: Commits on May 10, 2025
---------------------------------------------------
-

----------------------------------------------------------------------------------------
openmohaa.mk 0ea834788e29b4b4c81cee8bbb3f60ec77df2a94 # Version: Commits on May 09, 2025
----------------------------------------------------------------------------------------
Add documentation for running omohaaded in a Docker container,

----------------------------------------------------------------------------------------
retroarch.mk b590d843bcf8621ed99bb7209225a37c57bedf78 # Version: Commits on May 10, 2025
----------------------------------------------------------------------------------------
Fetch translations from Crowdin,

-------------------------------------------------------------------------------------
gzdoom.mk 58809a36890067a05f2cff1df4646b877815655b # Version: Commits on Apr 11, 2025
-------------------------------------------------------------------------------------
Fixed up game id

Store it in a proper buffer.,

-----------------------------------------------------------------------------------
tr1x.mk bccfb21cfd0bbac1b15c299c367d27485553b5ae # Version: Commits on May 08, 2025
-----------------------------------------------------------------------------------
creature: restore death state based on type ID

This ensures that post-load, a hybrid creature's correct state is

reinstated as the savegame will have stored the state and animation

against the original type ID in the level.

Resolves #2960.,

-----------------------------------------------------------------------------------
tr2x.mk bccfb21cfd0bbac1b15c299c367d27485553b5ae # Version: Commits on May 08, 2025
-----------------------------------------------------------------------------------
creature: restore death state based on type ID

This ensures that post-load, a hybrid creature's correct state is

reinstated as the savegame will have stored the state and animation

against the original type ID in the level.

Resolves #2960.,

-------------------------------------------------------------------------------------------------
libretro-geargrafx.mk 13f3fddd8a8054d7c5740a7d301b09a027f2ed79 # Version: Commits on May 10, 2025
-------------------------------------------------------------------------------------------------
Merge pull request #27 from Tatsuya79/main

change default lines,

------------------------------------------------------------------------------------------------
libretro-pokemini.mk 19095803f1434eb980db6e4004187a4b786e20b6 # Version: Commits on May 10, 2025
------------------------------------------------------------------------------------------------
Merge pull request #63 from sylverb/fix_savestates

Fix some savestates issues,

--------------------------------------------------------------------------------------------
libretro-puae.mk d3c925ef4fadee6c25bcef20d1f165141ba18ac3 # Version: Commits on May 09, 2025
--------------------------------------------------------------------------------------------
Add legacy note for keyboard pass-through option,

------------------------------------------------------------------------------------------------
libretro-puae2021.mk f2850ffcc850b33eb0e5dff7f170549f6423c71d # Version: Commits on May 09, 2025
------------------------------------------------------------------------------------------------
Add legacy note for keyboard pass-through option,

-----------------------------------------------------------------------------------------------
libretro-scummvm.mk f52ce6cf331d95f4f837f5fce5e8a46b4def335a # Version: Commits on May 09, 2025
-----------------------------------------------------------------------------------------------
RELEASE: This is 2.9.2pre,

-----------------------------------------------------------------------------------------------
libretro-tgbdual.mk 933707c0ba8f12360f6d79712f735a917713709a # Version: Commits on May 10, 2025
-----------------------------------------------------------------------------------------------
Merge pull request #34 from keithbowes/fix-double-free

Fix double-free crash,

--------------------------------------------------------------------------------------------
libretro-vice.mk 21cb8e48d15bff896515093a50b638f16bb57756 # Version: Commits on May 09, 2025
--------------------------------------------------------------------------------------------
Add legacy note for keyboard pass-through option,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-avm2 Area: AVM2 (ActionScript 3) hitTest Issues involving mouse picking and hitTest T-compat Type: Compatibility with Flash Player
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants