google/filament

crash on ios with _resourceLoader->loadResources(_asset);

Opened this issue · 1 comments

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=<no summary available>, buffer=<no summary available>, callback=<unavailable>) at SC3DModelView.mm:406:22
 frame #6: 0x0000000100a5a688 SoundCore-[SC3DBoxView createRenderablesFromPath:color:rgbColor:](self=<no summary available>, cmd=<no summary available>, model=<no summary available>, color=<no summary available>, rgbColor=<no summary available>) at SC3DBoxView.mm:330:9 
frame #7: 0x0000000100a5850c SoundCore-[SC3DBoxView reloadModelFromPath:color:rgbColor:](self=<no summary available>, _cmd=<no summary available>, modelPath=<no summary available>, color=<no summary available>, rgbColor=<no summary available>) at SC3DBoxView.mm:126:9
 frame #8: 0x0000000102fb9e10 SoundCoreSCA3134DeviceView.loadModelView(path=Swift.String @ scalar, color=Swift.String @ scalar, rgbColor=<no summary available>, self=<no summary available>) at SCA3134MainView.swift:336:29 
frame #9: 0x0000000101798f44 SoundCoreSCA3134MainViewController.refresh3DModel(fullModelPath=<unavailable>, self=<no summary available>) at SCA3134MainViewController.swift:530:29 
frame #10: 0x0000000101799680 SoundCoreprotocol witness for SCA3134MainPresenterProtocol.refresh3DModel(:) in conformance SCA3134MainViewController at <compiler-generated>:0
 frame #11: 0x0000000100f94d58 SoundCoreclosure #1 in closure #2 in SCA3134MainPresenter.fetch3DModel(completion=<unavailable>, full=<unavailable>, self=<no summary available>) at SCA3134MainPresenter.swift:397:32
 frame #12: 0x0000000100a7cd14 SoundCorethunk for @escaping @callee_guaranteed () -> () at <compiler-generated>: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<const uint8_t*>(buffer.bytes), static_cast<uint32_t>(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

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?

Can you provide the gltf you're using?