[iOS Metal] Warning / panic / crash can happen when allocating a lot of glb asset instances in default engine setup #7015
-
Hi Filament community, In my usecase, I need to load a simple glb asset like a unit cube (with textures) with 5000 instances on iOS w/ Metal. I am seeing warnings / panics / crashes. These can include: HandleAllocator arena full, Backend CommandStream overflow, random EXC_BAD_ACCESS on FEngine::loop (more details below). I expect 5000 not quite heavy and hope these issues are unexpected from engine side. Are these expected? Any solution towards this? (e.g. increase HandleAllocator arena size, metal command buffer size, any way of tracking their use dynamically?) I can repro using hello-gltf and my own app on the latest release 1.40.3. The glb asset (~70KB) is a cube with two JPG textures. The code snippet I am using: size_t numInstances = 5000;
std::vector<filament::gltfio::FilamentInstance *> tempInstances(numInstances,
nullptr);
app.asset = app.assetLoader->createInstancedAsset(
buffer.data(),
static_cast<uint32_t>(size),
tempInstances.data(),
tempInstances.size());
resourceLoader->loadResources(app.asset);
delete resourceLoader;
delete stbDecoder;
for (size_t i = 0; i < numInstances; i++) {
auto * instance = app.asset->getAssetInstances()[i];
scene->addEntities(instance->getEntities(), instance->getEntityCount());
}
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Are you compiling Filament yourself? If so, what happens if you increase |
Beta Was this translation helpful? Give feedback.
The solution is to use GPU hardware instancing instead of loading 5000 separate assets. Our gltfio library isn't set up to do this, but you can view a discussion here on hacking it yourself. Alternatively, create the cube geometry yourself instead of using gltfio.