API reference

GLTFStats Object

Process-wide counters that record how many times the C++ GLTF loader took the zero-copy mmap path (POSIX mmap of an external-storage file or AAsset_getBuffer of an APK asset) versus falling back to copy-into-vector via ReadWholeFile. Counters cover both the rendering loader (GLTFLoader.cpp) and the physics collision loader (GLTFCollision.cpp).
These counters are read directly from C++ (no logcat scraping); on-device tests should use GLTFStats.snapshot().
Typical usage from a test:
GLTFStats.reset()
loadModelThatReferencesSidecarBin(...)
val s = GLTFStats.snapshot()
assertTrue(
    s.sidecarMmap 0 || s.sidecarAssetMmap 0,
    "expected sidecar .bin to be zero-copied (mmap or AAsset_getBuffer); got $s",
)

All accessors are thread-safe (std::atomic on the C++ side). Counters are global and cumulative; reset to capture a load-scoped delta.

Signature

object GLTFStats

Methods

nativeGetStats ()
Signature
external fun nativeGetStats(): LongArray
Returns
LongArray
nativeReset ()
Signature
external fun nativeReset()
reset ()
Reset every counter to zero. Tests should call this before exercising a load.
Signature
fun reset()
snapshot ()
Snapshot the current counter values.
Signature
fun snapshot(): GLTFStats.Snapshot
Returns
GLTFStats.Snapshot

Inner Class

Snapshot Class

Modifiers: final
Snapshot of the five counters at a single point in time.

Signature

data class Snapshot(val primaryMmap: Long, val primaryAssetMmap: Long, val sidecarMmap: Long, val sidecarAssetMmap: Long, val copyFallback: Long)

Constructors

Snapshot ( primaryMmap , primaryAssetMmap , sidecarMmap , sidecarAssetMmap , copyFallback )
Signature
constructor(primaryMmap: Long, primaryAssetMmap: Long, sidecarMmap: Long, sidecarAssetMmap: Long, copyFallback: Long)
Parameters
primaryMmap: Long  POSIX mmap of the primary .glb / .gltf file (external-storage path).
primaryAssetMmap: Long AAsset_getBuffer of the primary .glb (uncompressed APK asset).
sidecarMmap: Long  POSIX mmap of an external sidecar .bin referenced by a .gltf.
sidecarAssetMmap: Long AAsset_getBuffer of a sidecar .bin (uncompressed APK asset).
copyFallback: Long  Number of times the loader fell back to ReadWholeFile (deflate-compressed APK asset, mmap failure, or a callback that returned a size mismatch).
Returns
GLTFStats.Snapshot

Properties

anyMmap : Long
[Get]
Total number of zero-copy paths taken (any flavor).
Signature
val anyMmap: Long
copyFallback : Long
[Get]
Number of times the loader fell back to ReadWholeFile (deflate-compressed APK asset, mmap failure, or a callback that returned a size mismatch).
Signature
val copyFallback: Long
primaryAssetMmap : Long
[Get]
AAsset_getBuffer of the primary .glb (uncompressed APK asset).
Signature
val primaryAssetMmap: Long
primaryMmap : Long
[Get]
POSIX mmap of the primary .glb / .gltf file (external-storage path).
Signature
val primaryMmap: Long
primaryZeroCopy : Boolean
[Get]
True iff the primary .glb was loaded via mmap (either POSIX or AAsset).
Signature
val primaryZeroCopy: Boolean
sidecarAssetMmap : Long
[Get]
AAsset_getBuffer of a sidecar .bin (uncompressed APK asset).
Signature
val sidecarAssetMmap: Long
sidecarMmap : Long
[Get]
POSIX mmap of an external sidecar .bin referenced by a .gltf.
Signature
val sidecarMmap: Long
sidecarZeroCopy : Boolean
[Get]
True iff a sidecar .bin was loaded via mmap (either POSIX or AAsset).
Signature
val sidecarZeroCopy: Boolean

Methods

minus ( other )
Compute the delta this - other. All fields are non-negative if other was earlier.
Signature
operator fun minus(other: GLTFStats.Snapshot): GLTFStats.Snapshot
Parameters
other: GLTFStats.Snapshot
Returns
GLTFStats.Snapshot