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: Allocate GameFileCache on GUI thread #11103

Merged
merged 5 commits into from Sep 29, 2022

Conversation

JosJuice
Copy link
Member

This is intended to fix https://bugs.dolphin-emu.org/issues/13053, which is a crash caused by sGameFileCache being null when addOrGet is called.

I've also included some other changes related to GameFileCacheManager. Please read the commits for details.

This is intended to fix https://bugs.dolphin-emu.org/issues/13053,
which is a crash caused by sGameFileCache being null when addOrGet
is called.
…lMetadata"

This reverts commit fb265b6.

The optimization in that commit is safe when the executor thread is
writing and the GUI thread is reading, but I had failed to take into
account that it's unsafe when the GUI thread is writing and the executor
thread is reading. (The native UpdateAdditionalMetadata function loops
through m_cached_files, which is unsafe if another thread is adding
elements to m_cached_files simultaneously.)

Losing out on this optimization isn't too bad, because
719930b makes it very unlikely that
both threads will want the lock at the same time.
Compared to the previous solution of using big `synchronized` blocks,
this makes GameFileCacheManager's executor thread release and re-lock
the lock when possible, giving the GUI thread a chance to do a
(comparatively) quick getOrAdd call if it needs to.
@lioncash lioncash merged commit 865348c into dolphin-emu:master Sep 29, 2022
11 checks passed
@JosJuice JosJuice deleted the android-gamefilecache-not-null branch September 29, 2022 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants