Skip to content

fix: Rename Dispatcher global name to avoid conflicts with Nitro#271

Merged
wcandillon merged 2 commits into
wcandillon:mainfrom
mrousavy:patch-1
Oct 17, 2025
Merged

fix: Rename Dispatcher global name to avoid conflicts with Nitro#271
wcandillon merged 2 commits into
wcandillon:mainfrom
mrousavy:patch-1

Conversation

@mrousavy
Copy link
Copy Markdown
Contributor

Since WebGPU uses an early copy of Nitro (kinda like a fork), there are some conflicts that users will run into when they install WebGPU in an app that already has Nitro Modules installed (or other way around).

An official full fix would be to migrate WebGPU to Nitro, not only for better maintenance, but also for better performance and stability. I really don't think the migration is a huge effort.

For now, this PR fixes the name of the Dispatcher that is injected into global, as Nitro uses the same name and when one of the two Nitro versions downcasts the global into the specific C++ symbol, we have conflics since it's two different C++ symbols - it's either nitro::margelo::Dispatcher (the official one) or the WebGPU margelo::Dispatcher.

It's essentially a race condition with no clear error log since its just a C++ pointer cast that fails (super hard to debug lol)

Fixes #270

Since WebGPU uses an early copy of Nitro (kinda like a fork), there are some conflicts that users will run into when they install WebGPU in an app that already has Nitro Modules installed (or other way around).

An official full fix would be to migrate WebGPU to Nitro, not only for better maintenance, but also for better performance and stability. I really don't think the migration is a huge effort.

For now, this PR fixes the name of the `Dispatcher` that is injected into global, as Nitro uses the same name and when one of the two Nitro versions downcasts the global into the specific C++ symbol, we have conflics since it's two different C++ symbols - it's either `nitro::margelo::Dispatcher` (the official one) or the WebGPU `margelo::Dispatcher`.

It's essentially a race condition with no clear error log since its just a C++ pointer cast that fails (super hard to debug lol)

Fixes wcandillon#270
@wcandillon
Copy link
Copy Markdown
Owner

@mrousavy should I also rename namespaces or it's not necessary?

@mrousavy
Copy link
Copy Markdown
Contributor Author

nope not necessary for two reasons;

  1. it's under margelo::, not margelo::nitro:: - so no conflicts i think.
  2. even if there were conflicts, as long as it's linked completely separately the c++ compiler would mangle the names to avoid conflicts. if it's separate .so/dylibs.

@wcandillon
Copy link
Copy Markdown
Owner

Thanks a lot!

@wcandillon wcandillon merged commit 4c83b4e into wcandillon:main Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash using webgpu with other nitro modules

2 participants