BrokenSource / DepthFlow

🌊 Image to → 2.5D Parallax Effect Video. A Free and Open Source ImmersityAI alternative
https://brokensrc.dev
GNU Affero General Public License v3.0
323 stars 21 forks source link

(BUG) Segmentation Fault on Apple Silicon when Compiling Shaders #13

Closed springyuniverse closed 1 month ago

springyuniverse commented 5 months ago

Hi I am running Depthflow on Mac Silicon and currently whenever I run depthflow I got

zsh: segmentation fault depthflow any ideas?

Tremeschin commented 5 months ago

Hello! It's a recently known and broader issue that affects ShaderFlow entirely atm :(

I don't have the hardware to test, but have bounced some ideas and tried a few things with a friend of mine Python developer from the USA that have it, but we couldn't find the root cause

Thanks for opening the issue, I should've done it earlier this week 👍🏻

Tremeschin commented 5 months ago

(my best idea and help needed)

After some inspection, it was quite clear that it happens right when compiling the shaders in this line, could well be unsupported types or extensions from Apple's implementation of OpenGL, as well as a bug in ModernGL Python wrapper, GLFW window, or macOS trying to use native ARM than x86_64 in compatibility mode with Rosetta (mayhaps even rye package manager installing x86 when it should do ARM?)

I'm not familiar with macOS to point at anything specific, but I will spin up a vm and debug myself eventually !

Tremeschin commented 1 month ago

Friend of mine let me use VSCode's live share feature and debug the code myself, after about 3 hours of work,,

image

I made it work on native Apple Silicon. There was an platform specific OpenGL undefined behaviour that NVIDIA/AMD/Intel was fine with, but segfaulted the shader compilation; and also the texture indexes must be in order on macOS, and guess what, it's fine for the others

currently only available from source https://brokensrc.dev/get/source/, will be part of the 0.6.0 release as some internal stuff changed

let me know if it works now!, also fixed some torch installation* issues

*didn't test the code to download a ffmpeg release, it might fail, in that case just brew install ffmpeg

Tremeschin commented 1 month ago

I've had a user or two on Discord this week on Apple Silicon M1/M2 reporting that it worked on git main, and I've just pushed v0.6.0 wheels on PyPI with these macOS fixes

there's probably an issue or two regarding downloading ffmpeg or the webui, I can debug further when I get access to the hardware again, worst case a brew install ffmpeg might be needed for exporting to videos

feel free to reopen if there's more opengl specifics of macos going bad :) !