atteneder / KtxUnity

Load KTX and Basis Universal textures at runtime
Apache License 2.0
223 stars 42 forks source link

WebGL Build Error - Plugins Colliding With Each Other #17

Closed DerrickBarra closed 4 years ago

DerrickBarra commented 4 years ago

Reported With Unity Version: 2020.1.4f1

Issue: When making a WebGL build, two .dll files collide, causing the build to fail.

Plugin 'ktx_unity.dll' is used from several locations: Packages/com.atteneder.ktx/Runtime/Plugins/x86_64/ktx_unity.dll would be copied to <PluginPath>/ktx_unity.dll Packages/com.atteneder.ktx/Runtime/Plugins/x86/ktx_unity.dll would be copied to <PluginPath>/ktx_unity.dll Please fix plugin settings and try again

How To Recreate:

Bug occurs in a blank project with just the KtxUnity plugin or even in the KtxUnity demo git repo.

atteneder commented 4 years ago

Hi @DerrickBarra,

Thanks for reporting!

This is strange. The DLLs are not required for building WebGL at all (the libktx_unity.bc is used). Might be a Unity bug. Unfortunately those happen to appear with the package manager sometimes. For me re-importing the whole project and restarting Unity helps (sometimes).

I'll be updating the native libs very soon and then I'll try to reproduce your steps.

Thanks, Andi

sybixsus commented 4 years ago

I can confirm that I've had this bug too and it does appear to be caused by the package manager. I removed the package, grabbed the repo manually via Git, and then copied the folders into the project manually and it has not happened again since then.

Might it be that the Editor loads one of the Windows DLLs when you're using play mode in the editor? And then when you go to build, it's still loaded?

DerrickBarra commented 4 years ago

@sybixsus @atteneder When I remove KtxUnity from the package manager, and then import it as a standard plugin, I'm getting a different error.

image

Reimporting all of my assets still shows the same issue with ktx_unity.dll.

@atteneder I'll try this in a completely blank project and see if the same thing occurs, and if you need I can open up a new Jira issue. I'm not entirely sure this new bug is related to the original one I reported.

sybixsus commented 4 years ago

@DerrickBarra Apologies that my suggestion has proven unhelpful. That particular plugin in the inspector looks identical for me as it does for you. I think the only difference (as far as I can see) is that I copied the entire "runtime" folder into the project as is. But I don't see why that would make any difference.

DerrickBarra commented 4 years ago

@atteneder @sybixsus What Unity version are you testing with? At this point, I've tested the following using the current stable version of KtxUnity (master branch).

Test 1 Create a blank Unity project in 2020.1.4f1. Add KtxUnity via the package manager.

Test 2 Create a blank Unity project in 2020.1.4f1. Add KtxUnity via the assets folder.

Test 3 Create a blank Unity project in 2020.1.4f1. Add KtxUnity via the assets folder. Remove the Plugins/x86 and Plugins/x86_64 folder and make a WebGL build.

Test 4 Same as Test 3, but try adding a TextureUrlLoader.cs component to a UI Image, so we can test loading a .basis file in a WebGL build.

And that's about as far as I can get in my testing of KtxUnity outside of working within the KtxDemo repo (which can't build to WebGL due to the windows dll name conflict errors).

Any ideas on other things I can try?

atteneder commented 4 years ago

Testing on macOS 2019.4 LTS only so far. You have to use the ktx_4.0.0_beta_4 branch and download and copy the native libs from the latest CI builds.

It's not really straight forward to test this half-ready state, but feel free to ask questions if you really want to test the bleeding-edge version.

That beinig said, I'm working hard to get the remaining native libs to build (Android mainly). After that a next beta release is likely to come soon (if you have the patience)

atteneder commented 4 years ago

Once the libs are ready, I'll test in 2020.1 as well and see if I run into similar problems.

DerrickBarra commented 4 years ago

@atteneder Thanks, I'm going to try the same test on the 2019.4.12f1 LTS version of Unity and I'll let you know.

DerrickBarra commented 4 years ago

@atteneder So I made a new blank 2019.4.12f1 LTS Unity project and grabbed the latest stable KtxUnity from the package manager. When making a WebGL build I still get the ktx_unity.dll plugin in multiple locations bug.

And when attempting to load a .basis file (my standard test) in the editor, I get an EntryPointNotFoundException. This occurs even after reimporting all of the assets in this empty demo project.

Next, I tested importing KtxUnity directly into the Assets folder in this 2019.4.12f1 project, and I get the same errors as my 2020.1 test. (ktx_unity.dll Unknown Architecture, and EntryPointNotFound)

Lastly, I took the project with KtxUnity added to the assets folder, and removed the x86 and x84_64 folders so I could make a WebGL build. And when the WebGL build still gets the EntryPointNotFound error.

DerrickBarra commented 4 years ago

@atteneder So using the latest beta with the new binaries, I'm no longer getting the "ktx_unity.dll plugin in multiple locations" bug, which is great!

EDIT: Once I modified my binaries to the appropriate settings per binary, I was able to successfully make WebGL and Android builds! Unity Editor doesn't work yet (EntryPointNotFound bug still), but I believe that's because the x86_x64 binaries still need to be updated correct?

atteneder commented 4 years ago

@atteneder So using the latest beta with the new binaries, I'm no longer getting the "ktx_unity.dll plugin in multiple locations" bug, which is great!

EDIT: Once I modified my binaries to the appropriate settings per binary, I was able to successfully make WebGL and Android builds! Unity Editor doesn't work yet (EntryPointNotFound bug still), but I believe that's because the x86_x64 binaries still need to be updated correct?

yes! will commit binaries today (cannot wait longer myself). it should be easy then.

atteneder commented 4 years ago

I've released Update 0.8.0. It should have the correct settings on the libraries.

Reopen if there's still issues.

Thanks!