V8 on Linux: documented but not wired up in CMake, and V8Platform doesn't build with V8 12+

Open
#2,088 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cmake, cpp

Research direction

Start with the V8 branches in Dependencies/JsRuntimeHost/Core/Node-API/CMakeLists.txt, which exist only for Android and Win32, and with the V8Platform.h and V8Inc.h headers. The issue also names the Xlib include order in the Unix Platform.h and DeviceImpl_Unix.cpp, plus the BUILDING.md section. Done means either a Linux V8 configure that compiles against V8 12+ or a BUILDING.md that no longer documents Linux V8. Maintainers need to choose between those two paths first.

Written by the indexing model from the issue text.

Description

Describe the bug
BUILDING.md describes building on Linux with -D NAPI_JAVASCRIPT_ENGINE=V8 and libv8-dev. However, Dependencies/JsRuntimeHost/Core/Node-API/CMakeLists.txt has V8 branches only for Android and Win32, so Linux stops with "Unsupported JavaScript engine: V8".

With a local Linux branch (headers plus the system libv8/libnode), we hit three more problems building against V8 12.4 (Fedora's Node 22):

  • V8Platform.h: V8 12 made CallOnWorkerThread, CallBlockingTaskOnWorkerThread, CallLowPriorityTaskOnWorkerThread, CallDelayedOnWorkerThread, PostJob and CreateJob non-virtual wrappers. Embedders now override PostTaskOnWorkerThreadImpl, PostDelayedTaskOnWorkerThreadImpl and CreateJobImpl, so the overrides fail to compile. TaskRunner likewise gained Post*TaskImpl.
  • X11 macros: Core/Graphics/Include/Platform/Unix/.../Platform.h includes <X11/Xlib.h>, whose macros (True, Status, …) break V8's headers when they come later in the same file (DeviceImpl_Unix.cpp).
  • V8Inc.h: the V8 inspector expects v8-inspector.h, which distribution V8 packages may not ship.

With those worked around (version-guarded Impl overrides, V8 headers included before Xlib, inspector off), the Playground runs on V8 12.4 on Linux. Under a V8 build, Babylon.js scenes and a large physics simulation behave the same as under JavaScriptCore.

Expected behavior
Either Linux V8 is supported (a CMake branch, plus V8Platform guarded for V8 ≥ 12), or BUILDING.md no longer documents it. We can send the V8Platform/V8ForegroundTaskRunner changes as a PR if that's wanted.

Other

  • Platform: Linux x64, Fedora 44, GCC 16, V8 12.4.254.21 (from Node 22.23).
Dominant language
C++
Stars
931
Forks
169
Avg merge
2d 17h
Merged PRs (30d)
66

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BabylonJS/BabylonNative

All issues in BabylonJS/BabylonNative

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.