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: Call UICommon::Init at app start instead of emulation start #8190

Merged
merged 4 commits into from
Aug 21, 2019

Conversation

JosJuice
Copy link
Member

Much of our native code assumes that UICommon::Init has been called (for reasons such as wanting to access the user's settings), so not calling it until emulation start heavily limits what native code we can use in the Android GUI (except during emulation).

This should not be merged before https://bugs.dolphin-emu.org/issues/11767 has been addressed, because the third commit of this PR makes that race condition worse if my thinking is correct.

}
});
// Registers the DirectoryStateReceiver and its intent filters
LocalBroadcastManager.getInstance(context).registerReceiver(
Copy link
Member

Choose a reason for hiding this comment

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

Is this a 1:1 thing? It feels like it would just be a list of receivers, each notified in turn when something happens.
If it is indeed a list, I'd expect any older invocations to still be alive; rendering the last paragraph of the comment above slightly fuzzy.
Unless we want it to be like that; then we're probably supposed to call unregisterReceiver in case directoryStateReceiver is not null.

...not that it matters too much, since you keep creating new instances in the places where it is used; so they'd likely end up running anyways.

Copy link
Member Author

@JosJuice JosJuice Jul 2, 2019

Choose a reason for hiding this comment

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

I was assuming that the old directoryStateReceiver would get deallocated once we create a new directoryStateReceiver, but I suppose that might not be true since the LocalBroadcastManager keeps a reference to it... Since I'm not entirely sure how it works, I think I'll just change the comment to say that multiple calls is not a supported use case, because that's how I've been thinking of it while writing the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I'll just delete the part of the comment that mentions multiple calls.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know, but if it works anything close to C# wrt the GC, it should still be referenced by the LocalBroadcastManager (and the closure itself should still be referencing the passed runnable, keeping it alive as well)

Copy link
Member Author

Choose a reason for hiding this comment

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

Disregard my previous comment – I've realized that multiple calls should not be encouraged, because if old DirectoryStateReceivers indeed are kept around (which is likely), the way we do unregistration means that newer calls will get dropped rather than old calls. I will make the comment say that multiple calls is not a supported use case.

@JosJuice JosJuice force-pushed the android-init branch 4 times, most recently from b1726ba to d4a21b8 Compare July 4, 2019 12:08
@Helios747
Copy link
Contributor

rebase pls

Much of our native code assumes that UICommon::Init has been called
(for reasons such as wanting to access the user's settings),
so not calling it until emulation start heavily limits what native
code we can use in the Android GUI (except during emulation).
@Helios747 Helios747 merged commit c7fc912 into dolphin-emu:master Aug 21, 2019
@JosJuice JosJuice deleted the android-init branch August 21, 2019 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants