Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit bf6b187a authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

Reapply "[res] Duplicate AssetManager when changes are needed"

This reverts commit 9dd30fb6

Changes: filter out duplicate assets when making a new
instance of AssetManager

Original comment:

[res] Duplicate AssetManager when changes are needed

When adding new apk paths to the ResourcesImpl's AssetManager,
we used to make it in a non-atomical way - first, the paths get
added without recalculating the internal indices, then later it
updates the indices and applies new configuration. This causes
some lookups to fail until the index recalculation, as apk
asset shift in the internal array, and the indices stop pointing
to the correct apks.

In this change, the asset paths update is now more parametrized:

- When creating a ResourcesImpl we know it's not being used yet,
so we just update the paths in place, and use the same non-
atomic, but the fastest, code

- When updating an existing object we instead create a new
AssetManager object with the new paths, and then use that
instead of the original one that could be in use

- this helps to keep the currently running lookups to be
  consistent, as the object can't change under the caller
  and suddenly start returning different resources
- an added bonus is that now we make sure that the paths
  actually change before running any update operations,
  potentially saving lots of time on heavy locking and JNI
  calls

+ Add a lock when accessing the registered shared libraries

Bug: 362700391
Test: manual, run a test app with a resources getter in a loop
  and verify it doesn't get NotFoundException
Flag: EXEMPT bugfix with no single point of entry
Change-Id: Ia957fec786d0b9426a7b33aa6747ef5c5d7681e9
parent 007140f0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment