crash on ios with _resourceLoader->loadResources(_asset);
- Dominant language
- C++
- Stars
- 20.5k
- Forks
- 2.3k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 83
Description
**Describe the bug**
when load model gltf with gltfView, got a crash , occurred in the method: _resourceLoader->loadResources(_asset);
i use filament ver : 1.50.2
```
(lldb) bt
thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x9998)
frame #0: 0x0000000103706380 SoundCoredraco::PointCloudDecoder::DecodeHeader(draco::DecoderBuffer*, draco::DracoHeader*) + 136
frame #1: 0x00000001036f17ac SoundCoredraco::Decoder::GetEncodedGeometryType(draco::DecoderBuffer*) + 64
frame #2: 0x0000000103791070 SoundCorefilament::gltfio::DracoMesh::decode(unsigned char const*, unsigned long) + 88 Message from debugger: Terminated due to signal 9
frame #3: 0x0000000103790f58 SoundCorefilament::gltfio::DracoCache::findOrCreateMesh(cgltf_buffer_view const*) + 200
frame #4: 0x000000010379a4c0 SoundCore`filament::gltfio::ResourceLoader::loadResources(filament::gltfio::FFilamentAsset*, bool) + 520
frame #5: 0x0000000100a612fc SoundCore-[SC3DModelView loadModelGltf:callback:](self=0x000000011ab9d380, _cmd=, buffer=, callback=) at SC3DModelView.mm:406:22
frame #6: 0x0000000100a5a688 SoundCore-[SC3DBoxView createRenderablesFromPath:color:rgbColor:](self=, cmd=, model=, color=, rgbColor=) at SC3DBoxView.mm:330:9
frame #7: 0x0000000100a5850c SoundCore-[SC3DBoxView reloadModelFromPath:color:rgbColor:](self=, _cmd=, modelPath=, color=, rgbColor=) at SC3DBoxView.mm:126:9
frame #8: 0x0000000102fb9e10 SoundCoreSCA3134DeviceView.loadModelView(path=Swift.String @ scalar, color=Swift.String @ scalar, rgbColor=, self=) at SCA3134MainView.swift:336:29
frame #9: 0x0000000101798f44 SoundCoreSCA3134MainViewController.refresh3DModel(fullModelPath=, self=) at SCA3134MainViewController.swift:530:29
frame #10: 0x0000000101799680 SoundCoreprotocol witness for SCA3134MainPresenterProtocol.refresh3DModel(:) in conformance SCA3134MainViewController at :0
frame #11: 0x0000000100f94d58 SoundCoreclosure #1 in closure #2 in SCA3134MainPresenter.fetch3DModel(completion=, full=, self=) at SCA3134MainPresenter.swift:397:32
frame #12: 0x0000000100a7cd14 SoundCorethunk for @escaping @callee_guaranteed () -> () at :0
frame #13: 0x000000010ed9cf50 libdispatch.dylib_dispatch_call_block_and_release + 32
frame #14: 0x000000010ed9eb34 libdispatch.dylib_dispatch_client_callout + 20
frame #15: 0x000000010edaefec libdispatch.dylib_dispatch_main_queue_drain + 1084
frame #16: 0x000000010edaeba0 libdispatch.dylib_dispatch_main_queue_callback_4CF + 44
```
method is here:
```
- (void)destroyModel {
if (!_asset) {
return;
}
_resourceLoader->evictResourceData();
_scene->removeEntities(_asset->getEntities(), _asset->getEntityCount());
_assetLoader->destroyAsset(_asset);
_asset = nullptr;
_animator = nullptr;
}
- (void)loadModelGltf:(NSData*)buffer callback:(ResourceCallback)callback {
[self destroyModel];
_asset = _assetLoader->createAsset(
static_cast(buffer.bytes), static_cast(buffer.length));
if (!_asset) {
return;
}
auto destroy = [](void*, size_t, void* userData) { CFBridgingRelease(userData); };
const char* const* const resourceUris = _asset->getResourceUris();
const size_t resourceUriCount = _asset->getResourceUriCount();
for (size_t i = 0; i < resourceUriCount; i++) {
const char* const uri = resourceUris[i];
NSString* uriString = [NSString stringWithCString:uri encoding:NSUTF8StringEncoding];
NSData* data = callback(uriString);
ResourceLoader::BufferDescriptor b(
data.bytes, data.length, destroy, (void*)CFBridgingRetain(data));
_resourceLoader->addResourceData(uri, std::move(b));
}
_resourceLoader->loadResources(_asset);
_animator = _asset->getInstance()->getAnimator();
_asset->releaseSourceData();
_scene->addEntities(_asset->getEntities(), _asset->getEntityCount());
}
```
**To Reproduce**
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Logs**
crashlog.crash on iphone 11 , ios 16.6
[crashlog.log](https://github.com/google/filament/files/14769688/crashlog.log)
**Desktop (please complete the following information):**
- OS: iOS 17.1.2 and iOS 16.6
- GPU: [e.g. NVIDIA GTX 1080]
- Backend: Metal
- Filament ver : 1.50.2
**Smartphone (please complete the following information):**
- Device: iphone 12 and iphone 11
- OS: 17.1.2
**Additional context**
Is there any solution to resolve this crash?
Contributor guide
Assessment
This issue has not been assessed yet.