Android: avoid main thread io and mmap the resource.car #682
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes a main thread IO to avoid ANR; allows Android to use mmap to load Lua code packages; and an additional Rtt_ASSERT correction.
Remove a main thread IO
There is a risk of ANR when
loadExpansionFiles()
in the main UI thread, so the main UI thread reading is changed to the main thread modifying the state, and the GLThread is used to read.Android to use mmap to load Lua code packages
This PR allows Android to load the Lua code package (resource.car) like other platforms, using mmap, to reduce runtime memory by extracting the resource.car at first launch. It doesn't need to be uncompressed every launch, so it also positively affects startup time.
During the public beta phase, it was observed that some models showed the situation where
AssetManager
prematurely returns -1 when decompressing resources (approximately 0.3%). This issue was resolved by improving the accuracy, reliability, and usability of theextractAssetFile()
method (at least this exception is no longer observed online). The worstcase scenario here is the same as before, when thegetBytesFromFile()
method failed to load the code package into memory all at once, resulting in a black screen after startup, but usually, it will not happen again when restarting the App.Rtt_ASSERT correction
Additionally, while debugging other issues, I found an
Rtt_ASSERT
that could not be false. After correcting it to match the context, I guess it's not allowed to moveDisplayObject
from theOrphanage()
group to theOrphanage()
group again, that is, toremoveSelf
repeatedly.Any suggestions are welcome. Thank you.