Closed Bug 1704911 Opened 4 years ago Closed 4 years ago

"Buffer is not mapped" error when running Emscripten WebGPU cube example

Categories

(Core :: Graphics: WebGPU, defect)

defect

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: kvark, Assigned: kvark)

References

Details

Attachments

(1 file)

Call stack:

wgpuBufferGetMappedRange(0, undefined) failed: InvalidStateError: GPUBuffer.getMappedRange: Buffer is not mapped 01-cubes:122:21
    printErr https://hugoam.github.io/two/bgfx/01-cubes:122
    _wgpuBufferGetMappedRange https://hugoam.github.io/two/bgfx/example-01-cubesDebug.js:6731
    wgpu::Buffer::GetMappedRange(unsigned long, unsigned long) const https://hugoam.github.io/two/bgfx/example-01-cubesDebug.wasm:1965872
    bgfx::webgpu::StagingBufferWgpu::map()::$_3::operator()(WGPUBufferMapAsyncStatus, void*) const https://hugoam.github.io/two/bgfx/example-01-cubesDebug.wasm:1380428
    bgfx::webgpu::StagingBufferWgpu::map()::$_3::__invoke(WGPUBufferMapAsyncStatus, void*) https://hugoam.github.io/two/bgfx/example-01-cubesDebug.wasm:1166973
    _wgpuBufferMapAsync

Internal assertion:

Assertion failure: mSegment (null segment), at /mnt/code/firefox/_webgpu/ipc/glue/Shmem.cpp:255
#01: mozilla::ipc::Shmem::RevokeRights(mozilla::ipc::Shmem::PrivateIPDLCaller) (/mnt/code/firefox/_webgpu/ipc/glue/Shmem.cpp:271)
#02: mozilla::ipc::IPDLParamTraits<mozilla::ipc::Shmem>::Write(IPC::Message*, mozilla::ipc::IProtocol*, mozilla::ipc::Shmem&&) (/mnt/code/firefox/_webgpu/ipc/glue/Shmem.cpp:444)
#03: mozilla::FunctionRef<void (IPC::Message*, mozilla::ipc::IProtocol*)>::FunctionRef<mozilla::webgpu::PWebGPUParent::OnMessageReceived(IPC::Message const&)::$_5::operator()(mozilla::ipc::Shmem&&) const::{lambda(IPC::Message*, mozilla::ipc::IProtocol*)#1}, int, (void*)0>()::{lambda(mozilla::FunctionRef<void (IPC::Message*, mozilla::ipc::IProtocol*)>::Payload const&, IPC::Message*, mozilla::ipc::IProtocol*)#1}::__invoke(mozilla::FunctionRef<void (IPC::Message*, mozilla::ipc::IProtocol*)>::Payload const&, IPC::Message*, mozilla::ipc::IProtocol*) (/mnt/code/firefox/_webgpu/obj-x86_64-pc-linux-gnu/dist/include/mozilla/FunctionRef.h:180)
#04: mozilla::ipc::IPDLResolverInner::ResolveOrReject(bool, mozilla::FunctionRef<void (IPC::Message*, mozilla::ipc::IProtocol*)>) (/mnt/code/firefox/_webgpu/ipc/glue/ProtocolUtils.cpp:947)
#05: std::_Function_handler<void (mozilla::ipc::Shmem&&), mozilla::webgpu::PWebGPUParent::OnMessageReceived(IPC::Message const&)::$_5>::_M_invoke(std::_Any_data const&, mozilla::ipc::Shmem&&) (/home/kvark/.mozbuild/clang/include/c++/7.4.0/bits/std_function.h:316)
#06: mozilla::webgpu::MapCallback(mozilla::webgpu::ffi::WGPUBufferMapAsyncStatus, unsigned char*) (/mnt/code/firefox/_webgpu/dom/webgpu/ipc/WebGPUParent.cpp:306)
#07: wgpu_core::device::fire_map_callbacks (/mnt/code/firefox/_webgpu/gfx/wgpu/wgpu-core/src/device/mod.rs:245)
#08: wgpu_core::device::queue::<impl wgpu_core::hub::Global<G>>::queue_submit (/mnt/code/firefox/_webgpu/gfx/wgpu/wgpu-core/src/device/queue.rs:832)
#09: wgpu_server_queue_submit (/mnt/code/firefox/_webgpu/gfx/wgpu_bindings/src/server.rs:580)
#10: mozilla::webgpu::WebGPUParent::RecvQueueSubmit(unsigned long, unsigned long, nsTArray<unsigned long> const&) (/mnt/code/firefox/_webgpu/dom/webgpu/ipc/WebGPUParent.cpp:396)
#11: mozilla::webgpu::PWebGPUParent::OnMessageReceived(IPC::Message const&) (/mnt/code/firefox/_webgpu/obj-x86_64-pc-linux-gnu/ipc/ipdl/PWebGPUParent.cpp:0)
#12: mozilla::layers::PCompositorManagerParent::OnMessageReceived(IPC::Message const&) (/mnt/code/firefox/_webgpu/obj-x86_64-pc-linux-gnu/ipc/ipdl/PCompositorManagerParent.cpp:200)
#13: mozilla::ipc::MessageChannel::DispatchAsyncMessage(mozilla::ipc::ActorLifecycleProxy*, IPC::Message const&) (/mnt/code/firefox/_webgpu/ipc/glue/MessageChannel.cpp:2155)
#14: mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message&&) (/mnt/code/firefox/_webgpu/ipc/glue/MessageChannel.cpp:2081)
#15: mozilla::ipc::MessageChannel::RunMessage(mozilla::ipc::MessageChannel::MessageTask&) (/mnt/code/firefox/_webgpu/ipc/glue/MessageChannel.cpp:0)
#16: mozilla::ipc::MessageChannel::MessageTask::Run() (/mnt/code/firefox/_webgpu/ipc/glue/MessageChannel.cpp:1959)
#17: nsThread::ProcessNextEvent(bool, bool*) (/mnt/code/firefox/_webgpu/xpcom/threads/nsThread.cpp:1150)
#18: NS_ProcessNextEvent(nsIThread*, bool) (/mnt/code/firefox/_webgpu/xpcom/threads/nsThreadUtils.cpp:548)
#19: mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) (/mnt/code/firefox/_webgpu/ipc/glue/MessagePump.cpp:303)
#20: MessageLoop::RunInternal() (/mnt/code/firefox/_webgpu/ipc/chromium/src/base/message_loop.cc:0)
#21: MessageLoop::Run() (/mnt/code/firefox/_webgpu/ipc/chromium/src/base/message_loop.cc:311)
#22: nsThread::ThreadFunc(void*) (/mnt/code/firefox/_webgpu/xpcom/threads/nsThread.cpp:393)
#23: _pt_root (/mnt/code/firefox/_webgpu/nsprpub/pr/src/pthreads/ptthread.c:204)
#24: ??? (/usr/lib/libpthread.so.0 + 0x95c6)
#25: clone (/usr/lib/haswell/libc.so.6 + 0x11e4d3)
#26: ??? (???:???)

Looks like a race condition: inserting a bunch of printf calls hides the error and makes this case to actually work.

Nvm, the change that hid the error was that the server content behind the URL was changed, to work around this very issue.
I'm preparing a fix shortly.

We are now passing an extra flag on Unmap to keep the shmem around.
Previously, we'd be freeing the Shmem accidentally on buffers that are writable and mapped at creation.
We also add a bit of logging on the WebGPUParent side.

Assignee: nobody → dmalyshau
Status: NEW → ASSIGNED
Pushed by dmalyshau@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4f124a8d83d1 Fix Shmem circulation for buffers that are both mappable and mapped at creation r=jgilbert
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: