babylonjs / babylonnative Goto Github PK
View Code? Open in Web Editor NEWBuild cross-platform native applications with the power of the Babylon.js JavaScript framework
License: MIT License
Build cross-platform native applications with the power of the Babylon.js JavaScript framework
License: MIT License
I tried to download .js script instead of loading resource assets using https on the GitHub raw repo. I get an CURLE_UNSUPPORTED_SCHEME error code from curl_url_set. Apparently it has something to do with proxies (?)
BROWSER CAPABILITIES
ARCHITECTURE
NATIVE ENGINE
Tools.LoadScript
to not depend on document
TEST INFRASTRUCTURE
DOCUMENTATION
CROSS PLATFORM
JAVASCRIPT INFRASTRUCTURE
Ordered by complexity
Call stack:
> TestApp.exe!bx::debugBreak() Line 38 C++
TestApp.exe!bgfx::CallbackStub::fatal(const char * _filePath, unsigned short _line, bgfx::Fatal::Enum _code, const char * _str) Line 70 C++
TestApp.exe!bgfx::fatal(const char * _filePath, unsigned short _line, bgfx::Fatal::Enum _code, const char * _format, ...) Line 438 C++
TestApp.exe!bgfx::setViewFrameBuffer(unsigned short _id, bgfx::FrameBufferHandle _handle) Line 4714 C++
TestApp.exe!babylon::NativeEngine::SetViewPort(const Napi::CallbackInfo & info) Line 1349 C++
TestApp.exe!Napi::ObjectWrap<babylon::NativeEngine>::InstanceVoidMethodCallbackWrapper::__l2::<lambda>() Line 3409 C++
TestApp.exe!Napi::details::WrapCallback<void * <lambda>(void)>(Napi::ObjectWrap<babylon::NativeEngine>::InstanceVoidMethodCallbackWrapper::__l2::void * <lambda>(void) callback) Line 61 C++
TestApp.exe!Napi::ObjectWrap<babylon::NativeEngine>::InstanceVoidMethodCallbackWrapper(napi_env__ * env, napi_callback_info__ * info) Line 3411 C++
TestApp.exe!`anonymous namespace'::ExternalCallback::Callback(void * callee, bool isConstructCall, void * * arguments, unsigned short argumentCount, void * callbackState) Line 172 C++
Looks like the ViewID mechanism is no longer functioning as it used to.
check NativeEngine::Impl::SetState
Remove the win32 code in console.cpp and allow for the client to register output functions/lambda. Test apps will be responsible for the output (outputDebugString, android_log_output,...)
Object URL and blobs are currently not supported in the Native Engine; they are "hacked out," as shown at the link. Implement in order to achieve feature parity, enabling load progress.
Spheres rendering differently than expected.
https://github.com/BabylonJS/BabylonNative/blob/master/TestApp/Scripts/experience.js#L12-L26
Pursuant to a conversation and changes in PR #30
https://github.com/BabylonJS/BabylonNative/blob/master/TestApp/Source/UWP/App.cpp#L240L243
DPI changes should likely be handled inside the platform-specific Runtime extensions (RuntimeWin32, RuntimeUWP, etc.) and only get communicated down to lower layers as resolution changes.
To access local files in the APK (scripts/*.js), Android asks to use an asset manager. You can't open the file directly and basically, it's not even a file in the filesystem but a bunch of bytes in a zip. For now, I've added a function, per platform that does the job if curl doesn't succeed at loading the resource.
Add support for extremely basic input (comparable to OpenXR's Khronos simple_controller
) for XR scenarios, including full routing up to Babylon. This will make it easier for Babylon.js to test and iterate on WebXR support using knowable and controllable inputs from the underlying implementation.
We're currently forcing BGFX to be single-threaded, which isn't its favorite thing to do, only because it aligned more directly with how we prototyped the integration. Evaluate what it would take/mean to enable multithreading in BgfxEngine.cpp.
When generating project with CMake, you can only create one testapp target.
We currently have a mixture of patterns for checking platforms throughout our CMakeLists.txt files, mixing variables like WINDOWS_STORE and APPLE in with our usage of BABYLON_NATIVE_PLATFORM. Let's discuss (here in this issue?) what the preferred pattern should be, then propagate pattern everywhere that makes sense and, if there are exceptions where the pattern should be broken, clearly designate these exceptions with comments.
Just a reminder here
microsoft/arcana.cpp#4
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.h
Lines 86 to 92 in 1b40d7b
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.h
Lines 175 to 185 in 1b40d7b
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.cpp
Lines 21 to 23 in 1b40d7b
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.cpp
Lines 539 to 543 in 1b40d7b
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.cpp
Lines 786 to 787 in 1b40d7b
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.cpp
Lines 1344 to 1353 in 1b40d7b
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.cpp
Lines 1375 to 1383 in 1b40d7b
Repro steps:
Result:
Every time the Runtime is recreated, memory usage climbs.
Expected Behavior:
All Runtime resources should be discarded successfully when the Runtime is recreated, so there should be no leftovers to occupy memory after pressing "R".
crossplatform audio engine
https://github.com/jarikomppa/soloud
Do you know any other one?
Centralising all the CURL issues here. This might be used as requirements for a CURL replacement.
libcurl eventually calls the C open API (which eventually calls CreateFileW), but this returns -1.
We currently have a fallback mechanism to use Windows::Storage::StorageFile::GetFileFromPathAsync instead, but it would be nice to see if we can get libcurl to work with broadFileSystemAccess.
Curl and local file access
To access local files in the APK (scripts/*.js), Android asks to use an asset manager. You can't open the file directly and basically, it's not even a file in the filesystem but a bunch of bytes in a zip. For now, I've added a function, per platform that does the job if curl doesn't succeed at loading the resource.
Issue moved to plugin #119
BabylonNative/Library/CMakeLists.txt
Lines 48 to 53 in ab9fd87
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
Our usage of libcurl is currently the blocking synchronous version. We should use the non-blocking asynchronous version.
resubmit PR with changes for 1 build system on Android
BabylonNative/Library/CMakeLists.txt
Lines 48 to 53 in ab9fd87
500Mb allocated while loading Sponza. It looks like a lambda capture. Any idea @bghgary ?
Override BGFX's default view order to ensure rendering happens in the order expected by the JavaScript engine.
Looks like something became incompatible as a result of the Promise
work done for the OpenXR integration.
Replace winrt::Windows::Web::Http::HttpStatusCode in XMLHttpRequest.h with something crossplatofmr (custom enum?)
In many places where we create JavaScript types using NAPI, we store off a copy of the constructor as a private static Napi::FunctionReference within the C++ type. This will probably not work if/once we have multiple simultaneous runtimes as the constructors for the second runtime will replace those of the first. Moreover, this is not probably not necessary, since the constructors should be owned by the JavaScript global context (at least in the majority of cases) and probably shouldn't be kept by native at all.
CMake 3min40 to generate solution per target on Azure with at least 2min30 taken only by libcurl
There must be some flags to change to speed up the solution generation time.
Work will require the XrPlugin to have access to the task chain, so should be undertaken after the work to switch NativeEngine to us runtime global state stored with NAPI so that XrPlugin can take advantage of the same mechanism.
The order of destruction is not quite working as intended in RuntimeImpl::BaseThreadProcedure right now. As it's currently written, the JavaScript environment (env
) is correctly tied to the lifetime of the thread on which it was created, which is strictly less than the lifespan of the RuntimeImpl itself. However, the dispatcher
and task
chain which represent the thread are actually members of the RuntimeImpl; therefore, they outlive the thread and are destroyed after the the thread has terminated; in other words, they strictly outlive env
. The problem with this is that the capturing lambdas we use inside the task system end up holding onto unsafe references (i.e., Napi::FunctionReference
) to objects that are owned by env
. These objects are of course destroyed when the env
dies, and the dispatcher
and task
chain's attempts to destroy them again therefore cause the program to crash on close.
I can currently think of two ways to address this. Option 1 is to manually clear the task
chain and dispatcher
in the shutdown phase of the thread, thereby causing them to be empty before the env
is destroyed (this will require changes to Arcana). Option 2 is to make the dispatcher
and task
chain not be members of the RuntimeImpl
, but instead make them beholden to the thread in the same way env
is, perhaps by encapsulating all this thread state in an object which can be used to guarantee destruction order. Option 2 is probably the more correct of these alternatives; it'll just require some minor rearchitecting of the RuntimeImpl
to achieve the desired result without losing the ability to enqueue work before the thread has actually started.
In a number of places, NativeEngine.cpp is using bgfx::copy to create locally owned copies of data from Babylon.js (this line, for example). This is probably redundant, as Babylon.js is already keeping copies to deal with device loss and other problems, so it should be possible to have the NativeEngine operate on refs alone so long as it's given access to the permanently-stored versions of data on the JavaScript side, not temporary copies. Fixing will require changes on both managed and native sides.
As a starting point, we want to try to separate out the Console callbacks in the runtime constructor and the NAPI object wrap of the Console into its own "module" and the TestApp is responsible for adding it if needed.
Future runtime objects will all be done using this kind of pattern.
V8 is not part of the repo. We will use Nugget or another package mgmt. to download it during build.
V8 .so must be placed in TestApp\Source\Android\app\src\main\jniLibs${ABI}
It's used to link against the Android app and copied by the gradle build system into the apk for dynamic JNI linking. .so for arm64, arm32, x86, x86-64 must be present when releasing a public apk.
Headers include is set in CMakeLists.txt external build of the Android TestApp.
Take care of commented deletion
https://github.com/BabylonJS/BabylonNative/pull/18/files#diff-0ac7323dc9a9ce79677fe03a04509a80L53
As GetArrayBufferAllocator method doesn't seem to be present
Here are the issues so far I've found while trying to compile for Android:
Avoid switching to xcode 11 if possible and find native functions. like NSBundle
Some problems I encountered:
JSC needs more work:
Right now, the only known missing feature for this is the ISwapChainPanel constructor path for RuntimeUWP. TODO and implementation starting point here:
BabylonNative/Library/Include/Babylon/RuntimeUWP.h
Lines 15 to 16 in ab9fd87
See BabylonJS/Babylon.js@baedfc7 for the stop gap solution.
Ideally, this should be done in the native layer so that we don't keep crossing the JS to native boundary.
For UWP, we have <rescap:Capability Name="broadFileSystemAccess" />
set in the manifest and have enabled in the settings to allow the app.
libcurl eventually calls the C open API (which eventually calls CreateFileW), but this returns -1.
We currently have a fallback mechanism to use Windows::Storage::StorageFile::GetFileFromPathAsync instead, but it would be nice to see if we can get libcurl to work with broadFileSystemAccess
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.