Closed blamay closed 3 years ago
Hi blamay, the first error is because the reflectbind mode is used by default. It's only available in editor runtime (at present). The second error is caused by the difference between editor and player runtime of Unity's dll. You could try to block the specific type (or type member) in CustomBinding process. If it still reports errors, I'll continue to follow up
Thank you very much for your reply. If I turn off reflectbind mode, generate bindings, and remove UnityEngine_UI_GraphicRebuildTracker.cs
, then I'm able to build without error and run JS. This is on unity version 2019.1.9f1
that comes with the clone.
But if I upgrade the project to 2020.3.13f1
or import jsb into an existing 2020.3.13f1
project, then I get this System.DllNotFoundException: quickjs
error after building. Things still work in the editor though. Do you know how I can fix this?
It seems the player runtime can not load the correct dll lib. Which target platform do you use? Firstly, check if the dll's target platform and architecture in Unity are correct, they will be scrambled in some situations. (the editor and the built app use different dll)
I'm hoping to build for PC, Mac, iOS and Android, but this was targeting macOS and 'Intel 64-bit + Apple silicon' Architecture. If I change Architecture to just 'Intel 64-bit', then the build works. Thanks for your help!
Using Intel 64-bit only is working for me for now, but it would be nice to have Apple silicon builds working at some point.
OK, I'll check how to build for Apple silicon.
I tried on macos with M1 chip. It seems ok with "Intel 64-bit and Apple silicon" settings for mac build. Could you give more details on it? Which version of Unity Editor are you using? And which commit of master
branch did you choose to build?
Thanks for giving it a try! That's encouraging that it worked for you on M1. I'm not actually using an M1 chip though, my MBP is a 2019 with an Intel chip. 'Intel 64-bit + Apple silicon' implies that it should work for both though.
This was on 2020.3.13f1
that I mentioned above. I'm not sure which commit it was but it was freshly cloned 7 days ago when I made the issue. XCode version 12.5.
I just downloaded 2020.3.14f1
and re-cloned jsb
at c9076d7
to double check.
Steps:
Created new unity project on 2020.3.14f1
Cloned jsb master at c9076d7
Moved everything from jsb into the new project except for the Packages folder and the ProjectSettings folder
Ran npm install
Loaded Examples/Scenes/SampleScene
with game_demo
Turned off reflect-bind mode
Generated Bindings & Type Definitions
Comment out compilation errors in compiled generated code:
Assets/Generated/OSX/UnityEngine_ParticleSystemRenderer.cs(1151,32): error CS1061: 'ParticleSystemRenderer' does not contain a definition for 'supportsMeshInstancing' and no accessible extension method 'supportsMeshInstancing' accepting a first argument of type 'ParticleSystemRenderer' could be found (are you missing a using directive or an assembly reference?)
Assets/Generated/OSX/UnityEngine_UI_DefaultControls.cs(281,17): error CS0200: Property or indexer 'DefaultControls.factory' cannot be assigned to -- it is read only
Built the game targeting macOS and 'Intel 64-bit + Apple silicon' Architecture
Run the build and see type initializer exception in the console. System.DllNotFoundException: quickjs
from the screenshot above.
If I change 'Intel 64-bit + Apple silicon' to just 'Intel 64-bit' and build, then everything works perfectly.
Hi blamay, I've tried and checked again. It works after updating the platform settings of quickjs.bundle. And I omitted the type members causing compilation errors you've mentioned. You can update and test again.
After pulling the latest changes from master
, there are no longer compilation errors from Generated files, and JS works when targeting 'Intel 64-bit + Apple silicon'!! Thank you so much for fixing this so quickly! This is a great project.
I do have another question though. Is it currently possible to perform JS Bridge > Generate Bindings and Type Definition
from CLI? It would be nice to be able to automate that for builds.
I'm glad to hear that, thanks 😄 Yes, you can do it through unity command line mode but maybe two build phases are required, the first for generating the glue code, and the second for the general build (I haven't checked this).
For example:
xxx\path\to\your\unity_executable -batchmode -nographics -executeMethod QuickJS.Unity.UnityHelper.GenerateBindingsAndTypeDefinition -projectPath path\to\your\project -quit
REM -nographics is not required when you are using macos or linux
Things are working great when I play the SampleScene normally, but when I 'Build and Run' the game I see the following error. Is there a step that I'm missing before building?![Screen Shot 2021-07-28 at 8 57 18 AM](https://user-images.githubusercontent.com/17733437/127357150-76a17c81-3d62-4b90-a555-cf1c8b480e1d.png)
Also, if I use "Generate Bindings and Type Definitions", I'm able to Play the scene but when I build I get some errors.![Screen Shot 2021-07-28 at 9 11 07 AM](https://user-images.githubusercontent.com/17733437/127358069-9a3c5a0c-06fd-4576-b457-4897084055eb.png)