netpyoung / unity.webp

:art: WebP made easy for Unity3d
https://netpyoung.github.io/unity.webp/
MIT License
237 stars 28 forks source link

MacOS - DllNotFoundException: webp #42

Open NikMikk opened 2 years ago

NikMikk commented 2 years ago

Hi!

We're using your wrapper inside our game and it works wonders, except on macOS. The .dll seems to not be included sometimes and sometimes it is but super rare.

Any thoughts on why this might happen?

NikMikk commented 2 years ago

It works on certain macOS devices but won't load on older laptops it seems, is it the DLL_NAME that works differently on older devices? Uploading Crash Report DllNotFoundException: Unable to load DLL 'webp': The specified module could not be found. at WebP.Texture2DExt.EncodeToWebP (UnityEngine.Texture2D lTexture2D) [0x00000] in <00000000000000000000000000000000>:0

netpyoung commented 2 years ago

well.. currently I built native library only x86_64 & arm64 versions for macOS.

Which mac model are you using for? Is that x86 marchine? and which version of unity.webp?

NikMikk commented 2 years ago

Our test laptop is a MacBook Air Early 2014 running Sierra 10.12.6 which is a x86_64 bit operating system

netpyoung commented 2 years ago

well. That issue seems be associated with this line : https://github.com/netpyoung/prebuilt-libwebp/blob/93d292d2d4afd5f13b6bd1049e0d8bc3f3a098f2/Rakefile#L214

I don't rememeber why I set minimum version 13.0. If modify script to minimum version to 10.12, It may will be work except webp's library build enviornment support that.

NikMikk commented 2 years ago

Ohh I see, that makes sense that it's not loading in at all haha.

So the webp's library build environment doesn't support anything lower than 13.0?

netpyoung commented 2 years ago

So the webp's library build environment doesn't support anything lower than 13.0?

Not sure, It need to check though out compiling it. but when I googling that It can be work, I will modify build script to 10.12 to check.

NikMikk commented 2 years ago

Awesome, thanks a ton!

NikMikk commented 2 years ago

Could the flag be removed completely? So it works on all 64 bit macOS devices

netpyoung commented 2 years ago

When remove that flag It gain compatibility but not can be impact on some perfomances. so instead of to remove that flag, I just down min version to 10.12

netpyoung commented 2 years ago

Could you try https://github.com/netpyoung/unity.webp/releases/tag/0.3.6 ?

NikMikk commented 2 years ago

I will give it a try on Monday!

NikMikk commented 2 years ago

It seems that we're still getting the Could not load DLL error, I will give it another go tomorrow as we've been moving around in our office all day. In other words, I didn't give it much time to make sure everything was correctly set up.

NikMikk commented 2 years ago

Nope still no progress, same error. :(

netpyoung commented 2 years ago

:( opps. The problem is I don't have testable mac device... to solving this issue It need to test modifying build parameters with machine.

Would you try to run build library script on your local machine remove that line? https://github.com/netpyoung/prebuilt-libwebp/blob/566248b5755428699188a0f11a0eef950823fda5/Rakefile#L214

NikMikk commented 2 years ago

I have no idea run that build script haha, I can give it a go if you help me out here a little first :)

Btw, we're using this in the game TOEM. We want to include you in the credits so if you want to be included, what do you want us to write?

netpyoung commented 2 years ago

It willl be better to support variable test macOs versions on github action but not. anyway to build library using buildscript

git clone https://github.com/netpyoung/prebuilt-libwebp.git
cd prebuilt-libwebp
bundle install

#modify build script maybe remove -mmacos-version-min=10.12 line on Rakefile then

rake update_library_ios

then this funtion will be produce bundle files on build/macos directory.

Did you made that? Wow. That game already in my library. It was cool! This repo just simple wrapper for webp. I'm just happy with that this repo helps a little people to develop something. I don't want anything.

NikMikk commented 1 year ago

Sorry for the radio silence!

Sorry for being such a noob but how do I build using buildscript / rake?? I've never used it before

This wrapper totally made TOEM's Quality of life update happen, we could double our photo capacity as the image sizes got so small!! We "only" use the decode/encode parts and removed the threading as it caused issues on the switch if lots of photos were loaded at the same time. Not enough mutexes

megavoid commented 1 year ago

I had a related issue - I need to convert WebP data to Texture2D and stumbled on this project. When testing this project on my ARM Mac I got a DllNotFoundException when trying to access the Texture2D conversion function.

I simply rebuilt the library on my ARM Mac with rake update_library_macos and finally got it to work.

I do not use this project right now as I only need two functions from the library. The webp.bundle and a small wrapper class is all I need:

using System;
using System.Runtime.InteropServices;

public class WebPWrapper
{

    [DllImport("webp")]
    public static extern int WebPGetInfo(byte[] data, ulong data_size, out int width, out int height);

    [DllImport("webp")]
    public static extern IntPtr WebPDecodeRGBA(byte[] data, ulong data_size, out int width, out int height);
}

The build script saved me, though. Thanks!

netpyoung commented 8 months ago

that problem cause by dependency path. so I fixed that using install_name_tool

 "com.netpyoung.webp": "https://github.com/netpyoung/unity.webp.git?path=unity_project/Assets/unity.webp#0.3.10",