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

avm1: fix buttons that were not clickable after a goto #10862

Merged
merged 11 commits into from Jul 14, 2023
Merged

avm1: fix buttons that were not clickable after a goto #10862

merged 11 commits into from Jul 14, 2023

Conversation

Flawake
Copy link
Contributor

@Flawake Flawake commented Apr 28, 2023

It is my first commit in this repo were I changed a serious amount of code.
This fixes issue #1108 and all underlying issues:
#8482, #8293, #9966, #10789, #7903, #7170, #6261, #4402
This is being done by placing removed displayObjects into a BTreeMap so we can use them again if there is a goto.
When the next frame begins the BTreeMap is emptied.

@Flawake Flawake marked this pull request as draft April 28, 2023 20:04
@Flawake Flawake marked this pull request as ready for review April 28, 2023 22:17
@Flawake Flawake marked this pull request as draft April 29, 2023 21:48
@Flawake Flawake marked this pull request as ready for review April 30, 2023 18:24
@adrian17 adrian17 requested a review from kmeisthax May 2, 2023 11:20
@adrian17
Copy link
Collaborator

adrian17 commented May 2, 2023

Pinging @kmeisthax / @Herschel , to me this feels like a hack that happens to work but isn't really how it's supposed to work under the hood - and doesn't feel like it matches Mike's original explanation from #1108 either? I can't say with certainty, I just have a bad hunch about it.

Also, we definitely want some extra tests for this.

@Flawake Flawake marked this pull request as draft May 2, 2023 20:31
@Flawake Flawake marked this pull request as ready for review May 6, 2023 11:14
Copy link
Member

@kmeisthax kmeisthax left a comment

Choose a reason for hiding this comment

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

So, the approach being taken here is to grab buttons out of the display tree but restore them if we need to recreate them. Mike explains this in terms of events being fired or not fired, but it doesn't have to be literally that. On the other hand, holding old buttons so we can bring them back does seem hacky.

Toad06's tests from issue #1108 would probably solve this dilemma. I don't see them incorporated into this PR - it might be helpful to see if they pass with these changes or not.

swf/src/types.rs Outdated Show resolved Hide resolved
@Flawake Flawake marked this pull request as draft May 9, 2023 13:59
@Flawake Flawake marked this pull request as ready for review May 21, 2023 15:44
@Flawake

This comment was marked as off-topic.

@iwannabethedev

This comment was marked as resolved.

@Flawake

This comment was marked as off-topic.

@iwannabethedev
Copy link
Contributor

That sounds good, if you have made extensive changes, I can try to take a look at it, but I think adrian17 and kmeisthax should also look at it at some point if you have made extensive changes.

Copy link
Member

@kmeisthax kmeisthax left a comment

Choose a reason for hiding this comment

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

It appears the new setup for this now is to check if the same object got reinstantiated; this seems viable. I'd approve and merge, but I did notice one flaw with how this is implemented: CharacterId isn't globally unique; you need to check both what character ID a display object was instantiated from and what movie that character came from. If you load two movies into the same stage, they both can have a "button 5", and this will falsely skip rollovers for them.

(If Flash actually doesn't check the source movie somehow, and multi-movie loads allow buttons from different movies to substitute for one another, ignore the following comments and instead add a NOTE comment documenting this.)

core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
Copy link
Member

@kmeisthax kmeisthax left a comment

Choose a reason for hiding this comment

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

One more thing: you need to compare SwfMovies by pointer instead of URL, since you can have two different movies with the same source URL.

core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
@Toad06
Copy link
Member

Toad06 commented May 31, 2023

Toad06's tests from issue #1108 would probably solve this dilemma. I don't see them incorporated into this PR - it might be helpful to see if they pass with these changes or not.

@kmeisthax These tests are edited with JPEXS and based on the file available in #4402 (as I don't have a Flash editor to make them properly). I only made them for quick manual testing purposes, so I think we shouldn't add them as part of the Ruffle test suite (each file is about 2mb and includes data that will not be relevant here - without mentioning potential copyright issues).

Copy link
Member

@kmeisthax kmeisthax left a comment

Choose a reason for hiding this comment

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

LGTM! I'm going to merge.

@Toad06 Gotcha on the tests, the new version of this PR has enough as is that I don't think we'll need yours anyway.

@kmeisthax kmeisthax enabled auto-merge (rebase) June 1, 2023 00:36
auto-merge was automatically disabled June 1, 2023 00:44

Rebase failed

Copy link
Member

@kmeisthax kmeisthax left a comment

Choose a reason for hiding this comment

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

So... it appeared the rebase failed and @adrian17 tried to clean it up. In Discord, he had a question I couldn't exactly answer: why do we need to run find_first_character_instance on down_object?

I'm assuming there's some subtlety of how buttons survive gotos that requires searching the whole display tree for a matching copy of the object, but I can't exactly prove that. Furthermore, the new_over_object code doesn't actually do this check, it just checks the id, depth, and movie for equality and then copies the state if it matches. Is there any particular reason why mouse_down_object can't work the same way?

Also, I noticed a bug in find_first_character_instance while trying to answer Adrian's question.

core/src/player.rs Outdated Show resolved Hide resolved
@Flawake
Copy link
Contributor Author

Flawake commented Jun 2, 2023

@kmeisthax we are seraching for the object because of this: when we are holding the button down and moving out of the button area. We should keep the button in it's mouse down state, so we need to check if the object is still there. We also can't check if the over object points at the button since the over object should remove it's reference when not hovered anymore.

core/src/display_object.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
Copy link
Member

@n0samu n0samu left a comment

Choose a reason for hiding this comment

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

I'm not experienced with reviewing PRs, but I read through the diff and tested it out, and everything is working well, plus the code looks sensible and fine. I think it's time to merge this! And thank you for your work!

core/src/player.rs Outdated Show resolved Hide resolved
core/src/player.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants