google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.35k stars 1.83k forks source link

New release crashes #7922

Closed mbalajee closed 2 weeks ago

mbalajee commented 2 weeks ago

Describe the bug I am building filament from source, I synced my fork and the performance just went north - GLBs that were loading at ease previously are now struggling to load in desktop (seeing a lot of errors & startup time is 5x times) and worse filament is crashing in Android

Changes I pulled causing the issue

Screenshot 2024-06-12 at 11 29 02 AM

Left - affected version (most recent), Right old version working fine

https://github.com/google/filament/assets/17508872/c75adf99-f15a-47dc-85aa-0c0a70ce9fcd

Logs:

PanicLog
in HandleBase::HandleId filament::backend::HandleAllocator<32, 48, 552>::allocateHandleSlow(size_t) [P0 = 32, P1 = 48, P2 = 552]:125
in file /Users/balajimurali/Documents/Code/Forks/Filament2/filament/backend/src/HandleAllocator.cpp
reason: HandleAllocator arena is full, using slower system heap. Please increase the appropriate constant (e.g. FILAMENT_OPENGL_HANDLE_ARENA_SIZE_IN_MB).
#0  gltf_viewer                            0x105c1199c utils::CallStack::update(unsigned long) + 32
#1  gltf_viewer                            0x105c11944 utils::CallStack::unwind(unsigned long) + 44
#2  gltf_viewer                            0x105c25a38 utils::details::panicLog(char const*, char const*, int, char const*, ...) + 212
#3  gltf_viewer                            0x104e11294 filament::backend::HandleAllocator<32ul, 48ul, 552ul>::allocateHandleSlow(unsigned long) + 384
#4  gltf_viewer                            0x104eefecc unsigned int filament::backend::HandleAllocator<32ul, 48ul, 552ul>::allocateHandleInPool<32ul>() + 128
#5  gltf_viewer                            0x104eefe0c unsigned int filament::backend::HandleAllocator<32ul, 48ul, 552ul>::allocateHandle<filament::backend::MetalVertexBuffer>() + 32
#6  gltf_viewer                            0x104eefdd0 filament::backend::Handle<filament::backend::MetalVertexBuffer> filament::backend::HandleAllocator<32ul, 48ul, 552ul>::allocate<filament::backend::MetalVertexBuffer>() + 24
#7  gltf_viewer                            0x104ec57f8 filament::backend::Handle<filament::backend::MetalVertexBuffer> filament::backend::MetalDriver::alloc_handle<filament::backend::MetalVertexBuffer>() + 28
#8  gltf_viewer                            0x104ec57ac filament::backend::MetalDriver::createVertexBufferS() + 24
#9  gltf_viewer                            0x104dc0d9c filament::backend::CommandStream::createVertexBuffer(unsigned int, filament::backend::Handle<filament::backend::HwVertexBufferInfo>) + 112
#10 gltf_viewer                            0x104dc06cc filament::FVertexBuffer::FVertexBuffer(filament::FEngine&, filament::VertexBuffer::Builder const&) + 748
#11 gltf_viewer                            0x104dc0fc4 filament::FVertexBuffer::FVertexBuffer(filament::FEngine&, filament::VertexBuffer::Builder const&) + 44
#12 gltf_viewer                            0x104d724b0 filament::FVertexBuffer* utils::Arena<utils::HeapAllocator, std::__1::mutex, utils::TrackingPolicy::DebugAndHighWatermark, utils::AreaPolicy::NullArea>::make<filament::FVertexBuffer, 4ul, filament::FEngine&, filament::VertexBuffer::Builder const&>(filament::FEngine&, filament::VertexBuffer::Builder const&) + 92
#13 gltf_viewer                            0x104d66ca4 filament::FVertexBuffer* filament::FEngine::create<filament::FVertexBuffer>(filament::ResourceList<filament::FVertexBuffer>&, filament::FVertexBuffer::Builder const&) + 44
#14 gltf_viewer                            0x104d66c6c filament::FEngine::createVertexBuffer(filament::VertexBuffer::Builder const&) + 40
#15 gltf_viewer                            0x104dc023c filament::VertexBuffer::Builder::build(filament::Engine&) + 1668
#16 gltf_viewer                            0x104b58a7c filament::gltfio::FAssetLoader::createPrimitive(cgltf_primitive const&, char const*, filament::gltfio::Primitive*, filament::gltfio::FFilamentAsset*) + 4320
#17 gltf_viewer                            0x104b55b8c filament::gltfio::FAssetLoader::createPrimitives(cgltf_node const*, char const*, filament::gltfio::FFilamentAsset*) + 876

Texture Decoder has 14 background threads.
PanicLog
in filament::RenderPass::RenderPass(FEngine &, const RenderPassBuilder &):128
in file /Users/balajimurali/Documents/Code/Forks/Filament2/filament/src/RenderPass.cpp
reason: RenderPass arena is full, using slower system heap. Please increase the appropriate constant (e.g. FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB).
#0  gltf_viewer                            0x105c1199c utils::CallStack::update(unsigned long) + 32
#1  gltf_viewer                            0x105c11944 utils::CallStack::unwind(unsigned long) + 44
#2  gltf_viewer                            0x105c25a38 utils::details::panicLog(char const*, char const*, int, char const*, ...) + 212
#3  gltf_viewer                            0x104cfb4ec filament::RenderPass::RenderPass(filament::FEngine&, filament::RenderPassBuilder const&) + 620
#4  gltf_viewer                            0x104cfb1f0 filament::RenderPass::RenderPass(filament::FEngine&, filament::RenderPassBuilder const&) + 44
#5  gltf_viewer                            0x104cfb198 filament::RenderPassBuilder::build(filament::FEngine&) + 380
#6  gltf_viewer                            0x104ce28a4 auto filament::PostProcessManager::structure(filament::FrameGraph&, filament::RenderPassBuilder const&, unsigned char, unsigned int, unsigned int, filament::PostProcessManager::StructurePassConfig const&)::$_4::operator()<filament::PostProcessManager::structure(filament::FrameGraph&, filament::RenderPassBuilder const&, unsigned char, unsigned int, unsigned int, filament::PostProcessManager::StructurePassConfig const&)::StructurePassData>(filament::FrameGraphResources const&, filament::PostProcessManager::structure(filament::FrameGraph&, filament::RenderPassBuilder const&, unsigned char, unsigned int, unsigned int, filament::PostProcessManager::StructurePassConfig const&)::StructurePassData const&, filament::backend::CommandStream&) + 176
#7  gltf_viewer                            0x104ce22b8 filament::FrameGraphPassConcrete<filament::PostProcessManager::structure(filament::FrameGraph&, filament::RenderPassBuilder const&, unsigned char, unsigned int, unsigned int, filament::PostProcessManager::StructurePassConfig const&)::StructurePassData, filament::PostProcessManager::structure(filament::FrameGraph&, filament::RenderPassBuilder const&, unsigned char, unsigned int, unsigned int, filament::PostProcessManager::StructurePassConfig const&)::$_4>::execute(filament::FrameGraphResources const&, filament::backend::CommandStream&) + 52
#8  gltf_viewer                            0x104dec8b8 filament::RenderPassNode::execute(filament::FrameGraphResources const&, filament::backend::CommandStream&) + 188
#9  gltf_viewer                            0x104ddbfd4 filament::FrameGraph::execute(filament::backend::CommandStream&) + 512
#10 gltf_viewer                            0x104d9c44c filament::FRenderer::renderJob(utils::ArenaScope<utils::Arena<utils::LinearAllocator, utils::LockingPolicy::NoLock, utils::TrackingPolicy::DebugAndHighWatermark, utils::AreaPolicy::HeapArea>>&, filament::FView&) + 10080
#11 gltf_viewer                            0x104d99b08 filament::FRenderer::renderInternal(filament::FView const*) + 128
#12 gltf_viewer                            0x104d99c78 filament::FRenderer::render(filament::FView const*) + 288
#13 gltf_viewer                            0x104d0ac9c filament::Renderer::render(filament::View const*) + 52
#14 gltf_viewer                            0x104943e64 FilamentApp::run(Config const&, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, unsigned long, unsigned long) + 7788
#15 gltf_viewer                            0x10491dbc8 main + 984

Command Arena arena: High watermark 2616 KiB (127%)
Command Arena arena: High watermark 2616 KiB (127%)
Command Arena arena: High watermark 2616 KiB (127%)
Command Arena arena: High watermark 2616 KiB (127%)
CommandStream used too much space (will block): needed space 2097152 out of 1125504, totalUsed=5165952, current=1050168, queue size=4 buffers

Load any larger model (with over 10K entities) & observe the log and load time of the model

Desktop (please complete the following information): Mac M3 Max / 64 GB

Smartphone (please complete the following information): Pixel 8 - Filament crashes when loading larger model (over 10K entities)

Additional context Unfortunately I couldn't share the models causing the issue as they're private to our customers but the issue can be reproducible on any larger models

mbalajee commented 2 weeks ago

I also checked out the main branch (to eliminate the local changes I made) & ran the gltf_viewer.cpp app and still seeing the issue

mbalajee commented 2 weeks ago

Tried updating the below constants before running the gltf sample from CLion but no luck,

Screenshot 2024-06-12 at 5 04 33 PM
mbalajee commented 2 weeks ago

Looks like changing in CMake file isn't enough, I changed the values inside the code & now i don't see the errors