Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] UVtools 3.0.0 - arm build not functional #431

Closed
rfield19 opened this issue Mar 12, 2022 · 140 comments
Closed

[BUG] UVtools 3.0.0 - arm build not functional #431

rfield19 opened this issue Mar 12, 2022 · 140 comments
Assignees
Labels
delayed Need to wait for something else to workout on this

Comments

@rfield19
Copy link

System

  • OS: OSX Monterey 12.3
  • UVtools version: 3.0.0

Describe the bug

ARM64 build for osx doesn't run.
Pops a window up with 'The application 'uvtools' can't be opened.'
(non arm64 build of uvtools works fine through rosetta, same as previous versions).

To Reproduce

Run uvtools on m1 mac
See error :)

Screenshots

Screenshot 2022-03-12 at 21 19 25

@rfield19
Copy link
Author

For thoroughness, have just tried it on a second M1 machine - same result unfortunately.

@sn4k3
Copy link
Owner

sn4k3 commented Mar 12, 2022

Yes i know. See related here: #187
You can run it via sh command, i dont know yet how to put it working via normal way since i have no mac m1 to try.
Need community help on here to debug this

To run via sh use a terminal on same UVtools path: sh UVtools.app/Contents/MacOS/UVtools.sh
You can create a shortcut for now

@sn4k3 sn4k3 added the help wanted Extra attention is needed label Mar 12, 2022
@rfield19
Copy link
Author

rfield19 commented Mar 12, 2022

Ah, ok sorry - I thought #187 was just the previous feature request for the arm build.
I'm 100% happy to test anything / everything on M1 machines you want to throw at me if that helps at all.

Regardless, congrats on releasing v3 though - you must be exhausted!

@sn4k3
Copy link
Owner

sn4k3 commented Mar 12, 2022

Ah, ok sorry - I thought 187 was just the previous feature request for the arm build.

It is. But problem was also spoted while i send some test builds there.

I'm 100% happy to test anything / everything on M1 machines you want to throw at me if that helps at all.

I really don't know where to start, i tried multiple things but sending packages for each try is painfull, i would need some remote access to an M1 to accelerate this and dump everything i can try.
One thing you can try is give run permission to all files within UVtools.app and also inspect app properties and see permissions

Regardless, congrats on releasing v3 though - you must be exhausted!

I had it on hold for some days by now. But not worth to keep it unreleased because of this situation

@rfield19
Copy link
Author

I have an update for you - might help, might make things worse! (let me know if you'd prefer me to post this in 187 instead)...

This is what I get when running 3.0.0 via sh method

Failed to load /UVtools.app/Contents/MacOS/libhostpolicy.dylib, error: dlopen(/UVtools.app/Contents/MacOS/libhostpolicy.dylib, 0x0001): tried: '/UVtools.app/Contents/MacOS/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
An error occurred while loading required library libhostpolicy.dylib from [/UVtools.app/Contents/MacOS/]

@sn4k3
Copy link
Owner

sn4k3 commented Mar 12, 2022

I have an update for you - might help, might make things worse! (let me know if you'd prefer me to post this in 187 instead)...

We can keep this thread as #187 was about the arm request and titled as such.

This is what I get when running 3.0.0 via sh method

Failed to load /UVtools.app/Contents/MacOS/libhostpolicy.dylib, error: dlopen(/UVtools.app/Contents/MacOS/libhostpolicy.dylib, 0x0001): tried: '/UVtools.app/Contents/MacOS/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) An error occurred while loading required library libhostpolicy.dylib from [/UVtools.app/Contents/MacOS/]

I don't know details about @aaaldo managed to run it via sh, but that error is strange, telling it's arm64 but need x64?

@rfield19
Copy link
Author

I thought the same thing - bit of an odd error on an m1 mac.
Perhaps it doesn't think the compiled binary is arm code?
I have a handy bit of software called SiliconInfo that tells me if it's arm or x64, but only if the software is running...

Anyway, the second m1 I've just tried it on (with a lot less libs installed on it), the sh script doesn't run at all as it can't find dotnet (line 3 of uvtools.sh).

I just installed dotnet via brew and got this fairly horrendous error!
I think it's mostly complaining that libcvextern isn't present in the contents/macos/ dir?

UVtools.app/Contents/MacOS/UVtools.sh: line 3: 46221 Killed: 9 ./UVtools
Unhandled exception. System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'cvextern' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libcvextern, 0x0001): tried: 'libcvextern' (no such file), '/usr/local/lib/libcvextern' (no such file), '/usr/lib/libcvextern' (no such file), 'Downloads/UVtools.app/Contents/MacOS/libcvextern' (no such file)
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.Init()
at UVtools.WPF.App.OnFrameworkInitializationCompleted() in D:\Tiago\Dropbox\Programming\C#\UVtools\UVtools.WPF\App.axaml.cs:line 198
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Avalonia.Threading.AvaloniaSynchronizationContext.<>c__DisplayClass5_0.b__0() in //src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs:line 33
at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run() in /
/src/Avalonia.Base/Threading/JobRunner.cs:line 181
at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in //src/Avalonia.Base/Threading/JobRunner.cs:line 37
at Avalonia.Native.PlatformThreadingInterface.SignaledCallback.Signaled(Int32 priority, Int32 priorityContainsMeaningfulValue) in /
/src/Avalonia.Native/PlatformThreadingInterface.cs:line 39
at Avalonia.Native.Interop.Impl.__MicroComIAvnSignaledCallbackVTable.Signaled(Void* this, Int32 priority, Int32 priorityContainsMeaningfulValue) in //src/Avalonia.Native/Interop.Generated.cs:line 4337
--- End of stack trace from previous location ---
at Avalonia.Native.PlatformThreadingInterface.RunLoop(CancellationToken cancellationToken) in /
/src/Avalonia.Native/PlatformThreadingInterface.cs:line 90
at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in //src/Avalonia.Base/Threading/Dispatcher.cs:line 65
at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in /
/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 120
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 209
at UVtools.WPF.Program.Main(String[] args) in D:\Tiago\Dropbox\Programming\C#\UVtools\UVtools.WPF\Program.cs:line 56
UVtools.app/Contents/MacOS/UVtools.sh: line 3: 46222 Abort trap: 6 dotnet UVtools.dll

@sn4k3
Copy link
Owner

sn4k3 commented Mar 12, 2022

I thought the same thing - bit of an odd error on an m1 mac.
Perhaps it doesn't think the compiled binary is arm code?
I have a handy bit of software called SiliconInfo that tells me if it's arm or x64, but only if the software is running...

Anyway, the second m1 I've just tried it on (with a lot less libs installed on it), the sh script doesn't run at all as it can't find dotnet (line 3 of uvtools.sh).

You dont need install dotnet since it's included on package. But if you do you need the 6.0.3.
If sh fails you better to call binary directly: ./UVtools.app/Contents/MacOS/UVtools

About libcvextern thats a common error when you missing any dependency.
I suspect ffpmeg need downgrade

brew install cmake ffmpeg@4
brew link ffmpeg@4

Reboot and retry

@rfield19
Copy link
Author

I thought the same thing - bit of an odd error on an m1 mac.
Perhaps it doesn't think the compiled binary is arm code?
I have a handy bit of software called SiliconInfo that tells me if it's arm or x64, but only if the software is running...
Anyway, the second m1 I've just tried it on (with a lot less libs installed on it), the sh script doesn't run at all as it can't find dotnet (line 3 of uvtools.sh).

You dont need install dotnet since it's included on package. But if you do you need the 6.0.3. If sh fails you better to call binary directly: ./UVtools.app/Contents/MacOS/UVtools

About libcvextern thats a common error when you missing any dependency. I suspect ffpmeg need downgrade

brew install cmake ffmpeg@4
brew link ffmpeg@4

Reboot and retry

dotnet definitely wasn't being picked up until I installed it via brew.

Slight improvement though - both machines are now identically producing that longer error message re libcvextern - the libhost error went away after I updated dotnet to latest version...

I'll try downgrading ffmpeg now!!

@rfield19
Copy link
Author

Result...
Downgrading ffmpeg on first machine, and installing ffmpeg on second machine (it didn't have it on there) did the trick...

Just got to figure out why it's only launching via sh now 😅

(and on benchmark, multithread score has jumped from 180 to 280!)

@sn4k3
Copy link
Owner

sn4k3 commented Mar 12, 2022

Result... Downgrading ffmpeg on first machine, and installing ffmpeg on second machine (it didn't have it on there) did the trick...
Just got to figure out why it's only launching via sh now 😅

Nice. The stange thing is the emulated version dont require downgrade...

(and on benchmark, multithread score has jumped from 180 to 280!)

You need to compare version 3.0 x64 with arm, if you comparing prior version it can have slower performance. NET 6.0 optimized some performance

@rfield19
Copy link
Author

Result... Downgrading ffmpeg on first machine, and installing ffmpeg on second machine (it didn't have it on there) did the trick...
Just got to figure out why it's only launching via sh now 😅

Nice. The stange thing is the emulated version dont require downgrade...

(and on benchmark, multithread score has jumped from 180 to 280!)

You need to compare version 3.0 x64 with arm, if you comparing prior version it can have slower performance. NET 6.0 optimized some performance

I'll try comparing to x64 3.0 ver later this eve.
Thought this wasn't too shabby for a laptop (the second m1 machine) - it's now beating your i9-9900k :)

SCR-20220312-val

@sn4k3
Copy link
Owner

sn4k3 commented Mar 12, 2022

Thought this wasn't too shabby for a laptop (the second m1 machine) - it's now beating your i9-9900k :)

I guess i need a new CPU 😂
But i hand't update that values since NET 5.0, need to re-run with NET 6.0 too

M1 is a good CPU

@aaaldo
Copy link

aaaldo commented Mar 12, 2022

I have an update for you - might help, might make things worse! (let me know if you'd prefer me to post this in 187 instead)...

We can keep this thread as #187 was about the arm request and titled as such.

This is what I get when running 3.0.0 via sh method
Failed to load /UVtools.app/Contents/MacOS/libhostpolicy.dylib, error: dlopen(/UVtools.app/Contents/MacOS/libhostpolicy.dylib, 0x0001): tried: '/UVtools.app/Contents/MacOS/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) An error occurred while loading required library libhostpolicy.dylib from [/UVtools.app/Contents/MacOS/]

I don't know details about @aaaldo managed to run it via sh, but that error is strange, telling it's arm64 but need x64?

hello everybody,

I ran this command :

sh /Applications/UVtools.app/Contents/MacOS/UVtools.sh

@bgyarfas
Copy link
Sponsor Contributor

bgyarfas commented Mar 13, 2022

@sn4k3 dotnet is definitely not being found

~/Downloads 
➜ sh UVtools.app/Contents/MacOS/UVtools.sh 
UVtools.app/Contents/MacOS/UVtools.sh: line 3: 75336 Killed: 9               ./UVtools
UVtools.app/Contents/MacOS/UVtools.sh: line 3: dotnet: command not found

I just got this M1 a couple weeks ago, haven't even installed homebrew yet.

dotnet doesn't appear to be anywhere in the .app either...

~/Downloads 
➜ find UVtools.app -name "*dotnet*"

~/Downloads 
➜ 

@sn4k3
Copy link
Owner

sn4k3 commented Mar 13, 2022

Again, you dont need dotnet install.
instead of sh use bash UVtools.app/Contents/MacOS/UVtools.sh
also all that script does is cd to UVtools.app/Contents/MacOS and run ./UVtools
It trigger the dotnet else because process have been killed by someother problem

All you need is downgrade ffpemg:

brew install cmake ffmpeg@4
brew link ffmpeg@4

@rfield19
Copy link
Author

rfield19 commented Mar 13, 2022

@sn4k3 Tiago, I think the confusion maybe is because you're thinking the script line

./UVtools || dotnet UVtools.dll

should be succesfully running ./UVtools, and only if it fails does it run 'dotnet UVtools.dll'.

Unfortunately though, ./UVtools command doesn't run - the process dies instantly, so then it does try to run 'dotnet UVtools.dll'!

Without dotnet being installed via brew in other words, it's not possible to run uvtools.
If you install dotnet via brew though, and then do a

cd UVtools.app/Contents/MacOS/
dotnet UVtools.dll

then UVtools works!

To put it another way - if you directly try to run 'UVtools.app/Contents/MacOS/UVtools' then it crashes out immediately with a process killed textline, so perhaps it's all a compile issue (may also be why it's necessary to use sh / bash at all, if the main UVtools binary isn't executable?)

*I have naturally also checked UVtools (in the Contents/MacOS/ dir) was chmod +x'ed, just to be sure!

@bgyarfas
Copy link
Sponsor Contributor

@sn4k3 Sorry, I misunderstood. I figured that "You don't need install dotnet since it's included on package...." meant there was a standalone dotnet somewhere in the app but more likely it's just build against dotnet. I'm downgrading ffmpeg right now and I'll let you know if that works.

@bgyarfas
Copy link
Sponsor Contributor

@sn4k3 After installing/downgrading ffmpeg I'm still getting the same error.

~/Downloads 
➜ which ffmpeg  
/opt/homebrew/opt/ffmpeg@4/bin/ffmpeg

~/Downloads 
➜ ffmpeg        
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 13.0.0 (clang-1300.0.29.3)
  configuration: --prefix='/opt/homebrew/Cellar/ffmpeg@4/4.4.1' --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-avresample --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

~/Downloads 
❯ bash UVtools.app/Contents/MacOS/UVtools.sh 
UVtools.app/Contents/MacOS/UVtools.sh: line 3:  1383 Killed: 9               ./UVtools
UVtools.app/Contents/MacOS/UVtools.sh: line 3: dotnet: command not found

~/Downloads 
❯ otool -L UVtools.app/Contents/MacOS/UVtools   
UVtools.app/Contents/MacOS/UVtools:
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

Let me know if there's some debugging/tracing I can do to track down the issue. I'll also see if I can get a local build going

@sn4k3
Copy link
Owner

sn4k3 commented Mar 13, 2022

@bgyarfas the netframework is all the other files you see in UVtools directory, but as @rfield19 told, it is unable to run without install and run via dotnet, which can mean a missing dependency or missing permition, can you guys just chmod all files within uvtools and give them +x, if it fails then try give full permitions of 777?

@rfield19
Copy link
Author

@bgyarfas the netframework is all the other files you see in UVtools directory, but as @rfield19 told, it is unable to run without install and run via dotnet, which can mean a missing dependency or missing permition, can you guys just chmod all files within uvtools and give them +x, if it fails then try give full permitions of 777?

Yep, tried that (set everything to 777 recursively) earlier to see if it would help! (it didn't...)
Same behaviour unfortunately - the uvtools binary dies immediately on launch.
SCR-20220313-vyb

@sn4k3
Copy link
Owner

sn4k3 commented Mar 14, 2022

Maybe it should be compiled on arm?
Can you try to build it there?

  • Clone this repo
  • Open a terminal on UVtools.WPF folder
  • Then run:
dotnet restore
dotnet publish -o "publish" -c Release -r osx-arm64 -p:PublishReadyToRun=true --self-contained
  • After you need to copy libcvextern.dylib from my package to that folder
  • Run ./UVtools

Does it works?

@rfield19
Copy link
Author

rfield19 commented Mar 14, 2022

dotnet publish $project -o "publish" -c Release -r osx-arm64 -p:PublishReadyToRun=true --self-contained

Blimey, compiled it - and running ./UVtools works...
But there's more!

Extrapolating from that, I then copied all the files from the publish dir into the UVtools.app/Contents/MacOS dir - and launching it from the app icon then works as well 👍

I then tried (on a fresh download of the release) only copying the UVtools binary into the MacOS dir and that wasn't launchable from the icon, but was still runnable from the sh method.

There must therefore be something in addition to the uvtools binary that it needs - and also must be necessary to compile the whole thing on an m1 machine I guess.

@rfield19
Copy link
Author

Link to new binary
https://we.tl/t-FnMTe3vo6U

@rfield19
Copy link
Author

... and from some further tests, the files that have changed in size on the new build compared to the release 3.0.0 are:

uvtools bin (of course)
UVtools.deps.json
UVtools.dll
UVtools.pdb
UVtools.runtimeconfig.json

@sn4k3
Copy link
Owner

sn4k3 commented Mar 14, 2022

There must therefore be something in addition to the uvtools binary that it needs - and also must be necessary to compile the whole thing on an m1 machine I guess.

Well that's not good news to me... I'm gona ask on dotnet git

UVtools.deps.json
UVtools.pdb
UVtools.runtimeconfig.json

Those files are not important, but the others are

I've updated the release build with yours :)
How does it fell compiling such project and making work for mac users? ;)

@rfield19
Copy link
Author

There must therefore be something in addition to the uvtools binary that it needs - and also must be necessary to compile the whole thing on an m1 machine I guess.

Well that's not good news to me... I'm gona ask on dotnet git

UVtools.deps.json
UVtools.pdb
UVtools.runtimeconfig.json

Those files are not important, but the others are

I've updated the release build with yours :) How does it fell compiling such project and making work for mac users? ;)

Neat - I hope it works ok for others.
@bgyarfas, maybe give it a go and see if it works for you also :)

It was extremely straightforward to compile it with your instructions though, so worst case m1 owners might have to compile their own version until/if you get an m1 machine.

I'm not sure about what the other files are that it needs though.
I'll do a proper diff on the directory and see if there's anything else that's changed.

@sn4k3
Copy link
Owner

sn4k3 commented Mar 14, 2022

I have asked here: dotnet/runtime#66574
If sign is required even your build will not work for others :/

until/if you get an m1 machine.

I'm up for offers 😂

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

Also, the run-uvtools file was not created on my desktop.

Auto installer script was changed to make that run-uvtools unnecessary, still testing...

Also, running the uvtools.sh inside the application bundle also fails:

Due previous statement brew and dotnet is not installed and so that script is not updated to reflect the change, which will be on next release.

I just tried the autobuild route and it gave me the openCV missing dependency problem.

Try with otool to see what is missing: otool -L /Applications/UVtools.app/Contents/MacOS/libcvextern.dylib

@dmopalmer
Copy link

otool -l gives:

 otool -L /Applications/UVtools.app/Contents/MacOS/libcvextern.dylib


/Applications/UVtools.app/Contents/MacOS/libcvextern.dylib (architecture arm64):
	@rpath/libcvextern.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2113.40.126)
	/opt/homebrew/opt/ffmpeg/lib/libavcodec.59.dylib (compatibility version 59.0.0, current version 59.37.100)
	/opt/homebrew/opt/ffmpeg/lib/libavformat.59.dylib (compatibility version 59.0.0, current version 59.27.100)
	/opt/homebrew/opt/ffmpeg/lib/libavutil.57.dylib (compatibility version 57.0.0, current version 57.28.100)
	/opt/homebrew/opt/ffmpeg/lib/libswscale.6.dylib (compatibility version 6.0.0, current version 6.7.100)
	/System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1557.5.4)
	/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
	/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.23.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1858.112.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

It not return any missing dependency as it can tell. I don't know but i think there is some compilation bug on macos opencv which allow ffmpeg to link. Both linux and windows builds do not link ffmpeg with the "mini" configuration. It was compiled on another Ventura.

What ffmpeg --version returns?

@dmopalmer
Copy link

dmopalmer commented Nov 27, 2022

The command line version I have for ffmpeg was installed by mambaforge (the M1 version of Python Anaconda).

When I remove the Mamba paths form my $PATH variable, ffmpeg is not found. (And I can't see any ffmpeg in the uvtools.app)

Which path should I be looking in?

My Mamba ffmpeg version:

✗ ffmpeg --version
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
  built with clang version 12.0.1
  configuration: --prefix=/Users/runner/miniforge3/conda-bld/ffmpeg_1645955491330/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl --cc=arm64-apple-darwin20.0.0-clang --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --disable-static --enable-version3 --enable-zlib --enable-libmp3lame --pkg-config=/Users/runner/miniforge3/conda-bld/ffmpeg_1645955491330/_build_env/bin/pkg-config --enable-cross-compile --arch=arm64 --target-os=darwin --cross-prefix=arm64-apple-darwin20.0.0- --host-cc=/Users/runner/miniforge3/conda-bld/ffmpeg_1645955491330/_build_env/bin/x86_64-apple-darwin13.4.0-clang
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Unrecognized option '-version'.
Error splitting the argument list: Option not found

% which ffmpeg
/Users/palmer/mambaforge/bin/ffmpeg

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

That ffmpeg looks outdated. The macOS by default ship with ffmpeg which on ventura I think should be v5 (Monterey comes with v5).
Can you try to update ffmpeg? ffmpeg@5

Another solution would be try to compile libcvextern.dylib on your system with removed Mamba paths form $PATH variable to see if it not link with ffmepg which is useless for UVtools and cause this troubles. If you want to try that first see here how

@dmopalmer
Copy link

I don't think ffmpeg comes with MacOS, but has to be installed.

Updating the Mamba-installed ffmpeg to 5.1.2 has no change in effect when I do the bash-curl install.

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

It should come in some sort of distribution, maybe libs only. Because prior to cv4.6.0 I always compiled full version which links ffmepg and intel version ran without any required installation. Comparing to linux users had to install ffmepg-dev in order to run UVtools but never on macOS. M1 users had to downgrade ffmepg to v4, indicating that v5 was by default on the system, maybe libs are but bin is not, I don't know.

Looking at otool output it gives:

/opt/homebrew/opt/ffmpeg/lib/libavcodec.59.dylib (compatibility version 59.0.0, current version 59.37.100)
/opt/homebrew/opt/ffmpeg/lib/libavformat.59.dylib (compatibility version 59.0.0, current version 59.27.100)
/opt/homebrew/opt/ffmpeg/lib/libavutil.57.dylib (compatibility version 57.0.0, current version 57.28.100)
/opt/homebrew/opt/ffmpeg/lib/libswscale.6.dylib (compatibility version 6.0.0, current version 6.7.100)

Which is telling you have ffmpeg libraries on /opt/homebrew/opt/ffmpeg/lib/ but you said you dont have homebrew, can you confirm that?

@dmopalmer
Copy link

I can confirm that I do not have Homebrew, and that there is no /opt/homebrew directory.

In fact, every library listed in the otool output is non-existent on my computer.

% ls -lsa /opt
total 0
0 drwxr-xr-x   5 root    wheel  160 Jul  5 22:43 .
0 drwxr-xr-x  20 root    wheel  640 Oct 28 02:43 ..
0 drwxr-xr-x   3 palmer  wheel   96 Jul  5 22:44 data
0 drwxr-xr-x   4 palmer  wheel  128 Feb 28  2021 datacache
0 drwxr-xr-x  14 root    wheel  448 Aug 20 12:45 local

Doing an ls on the otool output:

ls: /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation: No such file or directory
ls: /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate: No such file or directory
ls: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit: No such file or directory
ls: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa: No such file or directory
ls: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation: No such file or directory
ls: /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics: No such file or directory
ls: /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia: No such file or directory
...

Diving in:

tree /System/Library/Frameworks/AVFoundation.framework/Versions/A/      
/System/Library/Frameworks/AVFoundation.framework/Versions/A/
├── Frameworks
│   └── AVFAudio.framework -> ../../../../AVFAudio.framework
├── Resources
│   ├── BridgeSupport
│   │   ├── AVFoundation.arm64e.bridgesupport
│   │   └── AVFoundation.bridgesupport
│   ├── Info.plist
│   ├── libAVFAudio.dylib -> ../../../../AVFAudio.framework/Versions/A/AVFAudio
│   └── version.plist
└── _CodeSignature
    └── CodeResources

5 directories, 6 files

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

Ok, so can you try to build the libcvextern.dylib as indicated (Without ffmepg on path) so maybe we can get rid of it? And then bundle that to users....
Build requires you to install git, xcode, cmake, mono and dotnet-sdk 6.0
Do not install dependencies via my script or it will install homebrew to do such

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

Here what dylib should look without ffempg: (My x64 build)
image

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

Another command you can try to fetch dependencies (see if output different from otool):
dyld_info -dependents /Applications/UVtools.app/Contents/MacOS/libcvextern.dylib

@dmopalmer
Copy link

I don't know how to build libcvextern.dylib.

The output of that dyld_info is

dyld_info -dependents /Applications/UVtools.app/Contents/MacOS/libcvextern.dylib   
/Applications/UVtools.app/Contents/MacOS/libcvextern.dylib [arm64]:
    -dependents:
        attributes     load path
                       /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
                       /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
                       /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
                       /usr/lib/libSystem.B.dylib
                       /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
                       /opt/homebrew/opt/ffmpeg/lib/libavcodec.59.dylib
                       /opt/homebrew/opt/ffmpeg/lib/libavformat.59.dylib
                       /opt/homebrew/opt/ffmpeg/lib/libavutil.57.dylib
                       /opt/homebrew/opt/ffmpeg/lib/libswscale.6.dylib
                       /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation
                       /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
                       /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia
                       /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
                       /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
                       /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
                       /usr/lib/libc++.1.dylib
                       /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
                       /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
                       /usr/lib/libobjc.A.dylib

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

I don't know how to build libcvextern.dylib.

you just need to follow and run this script

The output of that dyld_info is

Looks same as otool, but the problem is clear that ffmepg expected on /opt/homebrew but not present on your system.

@dmopalmer
Copy link

That script looks like it installs brew around line 56.

@sn4k3
Copy link
Owner

sn4k3 commented Nov 27, 2022

That script looks like it installs brew around line 56.

Yes, you can comment or remove that section but you need to manually install that dependencies

@dmopalmer
Copy link

Frankensteining together macports and conda installs of various packages, the script eventually gives error messages, but does produce .dylibs:

(uvtools) ➜  ~ ls -lsh emgucv/**/*.dylib
22312 -rwxr-xr-x  1 palmer  staff    11M Nov 28 22:28 emgucv/Emgu.CV.Example/DynamicImage.Asp.NetCore/bin/Release/net7.0/libcvextern.dylib
22312 -rwxr-xr-x  1 palmer  staff    11M Nov 28 22:28 emgucv/Emgu.CV.Example/HelloWorld/bin/Release/net6.0/libcvextern.dylib
22280 -rwxr-xr-x  1 palmer  staff    11M Nov 28 22:28 emgucv/libs/runtimes/osx/native/arch/libcvextern-arm64.dylib
22280 -rwxr-xr-x  1 palmer  staff    11M Nov 28 22:28 emgucv/libs/runtimes/osx/native/arm64/libcvextern.dylib
22312 -rwxr-xr-x  1 palmer  staff    11M Nov 28 22:28 emgucv/libs/runtimes/osx/native/libcvextern.dylib

The error message is:

  Failed to restore /Users/palmer/emgucv/Emgu.CV.Test/Emgu.CV.Test.Netcore/Emgu.CV.Test.Netcore.csproj (in 4.77 sec).
  1 of 4 projects are up-to-date for restore.
make[2]: *** [Emgu.CV.Test.Netcore] Error 1
make[1]: *** [Emgu.CV.Test/CMakeFiles/Emgu.CV.Test.Netcore.dir/all] Error 2
make: *** [all] Error 2

The otool output of one of them is:

(uvtools) ➜  ~ otool -L emgucv/libs/runtimes/osx/native/libcvextern.dylib 
emgucv/libs/runtimes/osx/native/libcvextern.dylib (architecture arm64):
	@rpath/libcvextern.dylib (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2297.0.0)
	/System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1690.0.0)
	/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
	/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.32.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1953.1.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1953.1.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

Are any of the .dylib files useful?

@sn4k3
Copy link
Owner

sn4k3 commented Nov 29, 2022

Nice, ffmpeg is gone!

please try: cp -f emgucv/libs/runtimes/osx/native/libcvextern.dylib /Applications/UVtools.app/Contents/MacOS/ and run UVtools, does it work now?

Zip folder emgucv/libs/runtimes/osx, upload here or upload somewhere and attach link here

@dmopalmer
Copy link

It works!

Here is the zip file.

osx.zip

@sn4k3
Copy link
Owner

sn4k3 commented Dec 1, 2022

Thanks, will update dylib with your in next release.

sn4k3 added a commit that referenced this issue Dec 1, 2022
- **File formats:**
  - (Add) File extension: .gktwo.ctb to `ChituboxFile` to be able to convert files for UniFormation GKtwo under special CTB format
  - (Add) UniFormation GKtwo compatibility under CTB format, if exporting JXS rename to CTB before open
  - (Fix) CTB, CBDDLP, PHOTON, FDG, PHZ: Read and write files larger then 4GB (#608)
- **PCB Exposure:**
  - (Add) Offset X/Y to offset the PCB from it origin
  - (Add) Allow to toggle between "Show preview image cropped by it bounds" and "Show full preview image (The final result)"
  - (Improvement) Use rectangle instead of line for center line primitive (#607)
  - (Fix) Implement rotation to polygon and center line primitives (#607)
  - (Fix) Macros in a single line was not being parsed (#607)
  - (Fix) Invert color per file was not affecting primitives
- **Network printers:**
  - (Add) Socket requests with TCP and UDP
  - (Add) AnyCubic printer preset (However it can't upload a file)
  - (Add) Scripts in request path to allow a first request to fetch data to the final request:
    -  A script starts with **<\?** and ends with **?>**
    -  First parameter is the first request to get response content from
    -  Second parameter is the regex pattern to match content with
    -  Third parameter is the final request that supports a parameter from regex matching group, eg: **{#1}** is match Group[1] value
    -  **Example:** <\? getfiles > {0}\/(\d+\.[\da-zA-Z]+), > printfile,{#1} ?>
  - (Change) Allow to print a filename without send it when upload request path is empty
  - (Fix) Do not show printers with empty requests
- (Change) Default layer compression to Lz4 instead of Png
- (Improvement) Application is now culture aware but set part of `NumberFormat` to the `InvariantCulture.NumberFormat`
- (Improvement) Material cost now show with the current culture currency symbol due previous change
- (Improvement) Better submit of bug reports using sections and forms
- (Improvement) Linux: AppImage now have a help manual with possible arguments and parameters
- (Improvement) macOS: Codesign app on auto-installer and auto-upgrade to bypass arm64 run restriction (#431)
- (Improvement) macOS: Rebuilt arm64 libcvextern.dylib to run with less dependencies (#431)
- (Improvement) macOS: Try to show missing dependencies from openCV (if any) on the error message
- (Fix) UI: layers sorted lexicographically instead of numerically in the issues list view (#611)
- (Fix) PrusaSlicer printer parameters: UniFormation GKtwo
@sn4k3
Copy link
Owner

sn4k3 commented Apr 22, 2023

Need to compile recent OpenCV on M1 again, can anyone compile it? @dmopalmer
Just need to run: bash libcvextern.sh 4.7.0 --> Make sure to use 4.7.0 branch if asked

@dmopalmer
Copy link

Done. Zip attached.

(For my reference:

conda activate uvtools
cd ~/Desktop/tmp/emugcv
/Users/palmer/repo/notmine/uvtools_stuff/libcvextern.sh 4.7.0
# Let it run
open emgucv-4.7.0/lib

and zip the runtimes and attach.)

runtimes.zip

@sn4k3
Copy link
Owner

sn4k3 commented Apr 22, 2023

@dmopalmer I've updated the compilation script to remove a video dependency useless to UVtools. Can you redownload the script, remove compilation folder and re-compile?
Sorry for the trouble

@dmopalmer
Copy link

Done.
runtimes.zip

@sn4k3
Copy link
Owner

sn4k3 commented Apr 23, 2023

Perfect! Thanks once again!

@sn4k3 sn4k3 closed this as completed Apr 23, 2023
@danylkaaa
Copy link

Hi! recently I found that I also have problem with launching UVtools on M2. I tried to install dotnet runtime, ffmpeg@4. But only thing that helped to me was

codesign --force --deep --sign - UVtools.app

@sn4k3
Copy link
Owner

sn4k3 commented Jan 4, 2024

@danylkaaa this is an old topic. The dependencies you installed are not required.
Please use UVtools auto installer script.

@jpjokela
Copy link

Hi! recently I found that I also have problem with launching UVtools on M2. I tried to install dotnet runtime, ffmpeg@4. But only thing that helped to me was

codesign --force --deep --sign - UVtools.app

Thanks, this fixed 4.3.2 installation on my ARM mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delayed Need to wait for something else to workout on this
Projects
None yet
Development

No branches or pull requests