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

Android: Disallow multiple launcher activities #8860

Merged
merged 1 commit into from Jun 16, 2020
Merged

Conversation

Ebola16
Copy link
Member

@Ebola16 Ebola16 commented Jun 9, 2020

Copy link
Contributor

@sepalani sepalani left a comment

Choose a reason for hiding this comment

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

Isn't there a cleaner way to know if the activity's launching/running rather than adding another static?

@Ebola16
Copy link
Member Author

Ebola16 commented Jun 15, 2020

@Tilka (I think you were flacs from IRC) After the IRC discussion, I looked at the code again. I think launch() and launchfile() are actually called from the same thread. Those methods eventually trigger EmulationFragment.runWithValidSurface(), which is where concurrent threads are made. At least I'm pretty sure that's what's going on here, still shaky with thread safety.

@sepalani I looked into a few options to see if I could detect if the NativeEmulation thread is already running. Thread.isAlive() was a possibility but I've read a few reports saying that it's unreliable during thread startup. Other options were more complicated than necessary from what I've read. The static boolean seems to work.

@Ebola16 Ebola16 force-pushed the Emu branch 2 times, most recently from 578a3ec to 86b75f2 Compare June 15, 2020 09:47
Copy link
Contributor

@sepalani sepalani left a comment

Choose a reason for hiding this comment

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

It turns out that from what I read, the boolean variable is the only/simplest method so far to prevent an event from firing twice. Even disabling the element won't work as multiple events can be in the queue and will be handled before disabling it.

@Ebola16
Copy link
Member Author

Ebola16 commented Jun 15, 2020

@sepalani Good to hear we found the same thing on using a boolean here. Is the new variable naming scheme acceptable now?

@sepalani
Copy link
Contributor

@Ebola16 The naming is better, IMO. You just need to rename finishedLaunchingEmulation to something more fitting.

The other alternative I found regarding this issue is using a lock (mutex) but I'm not well versed in Android to know if it's the Android-way of handling this.

@Ebola16
Copy link
Member Author

Ebola16 commented Jun 16, 2020

@sepalani Hopefully the latest version of this PR solves the naming problems. I tried a lock object (like the one in #8833) but ended up getting an ANR since I was making the UI thread wait.

@Tilka Tilka merged commit a2b7627 into dolphin-emu:master Jun 16, 2020
@Ebola16 Ebola16 deleted the Emu branch June 16, 2020 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants