artoolkitx / arunityx

artoolkitX for Unity, providing high-performance video acquisition, marker and texture tracking and full Unity Editor support
https://www.artoolkitx.org/
Other
43 stars 22 forks source link

Android Issues - Cache Dir Access for Runtime-Created Markers #25

Closed OptrixAU closed 1 year ago

OptrixAU commented 5 years ago

When running on Android, the Load() function kicks off a call to unpackStreamingAssetToCacheDir()

This appears to work correctly when the markers are pre-configured (ie. you create the ARTrackable in the scene and build it in).

However, if your markers are created at runtime, you get an UnauthorizedAccessException each time Load is called for a runtime marker when attempting to access the cache directory in Unity 2018.4 (the long-term-support version).

You get the following log message in logcat: Access to the path '/storage/emulated/0/Android/data/application id/cache' is denied.

Is ARToolkitX somehow locking the cache folder? I've noticed that the cache folder is passed to ARToolkitX as a parameter to the video in Android versions. Perhaps we instead need to create a subfolder for the video cache?

OptrixAU commented 5 years ago

Turns out that there are MANY different calls to Load that can be triggered during creation of a runtime marker. If any of these happen before we attempt to set a marker Type (which itself triggers a load), it attempts to load a 2D marker from streamingAssets.

There wasn't much exception handling in that function, so it broke the function.