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

macOS Support #272

Open
6 tasks done
rodlie opened this issue Oct 20, 2024 · 109 comments · Fixed by #284
Open
6 tasks done

macOS Support #272

rodlie opened this issue Oct 20, 2024 · 109 comments · Fixed by #284
Assignees
Labels

Comments

@rodlie
Copy link
Member

rodlie commented Oct 20, 2024

Issue tracking macOS support.

  • Make it buildable
  • Fix memory issue
  • Refactor color picker drop tool
  • Gestures
  • Make SDK for binary release
  • Workaround Audio issues (need a proper fix, in the future)

When done we can offer an unsigned macOS 12.7 x86-64 compatible build.

Support for macOS beyond 12.7, Apple Silicon, notarized will require funding.

@rodlie rodlie self-assigned this Oct 20, 2024
@pgilfernandez
Copy link

Awesome!
Any help/doc on how to build the macos branch for testing and helping?

Thanks

@rodlie
Copy link
Member Author

rodlie commented Oct 20, 2024

Will update BUILD.md tomorrow, it's getting late here.

Requirements are simple: apple clang 14+, cmake, ninja, pkgconfig, Qt 5.15, QScintilla and FFmpeg (will build on <7, but does not work properly on anything over 4.2.x).

Currently there is a small build "issue", as we bundle the gn.bin binary needed to build the engine (skia), macOS will refuse to run it since it's not signed (the old right-click trick still works here). Might need to add instructions on how to build gn from source to avoid the signed issue.

@rodlie
Copy link
Member Author

rodlie commented Oct 21, 2024

Why supporting Apple ARM requires funding? Can't you simply build it using github ci and try it on a VM?

For a platform to be supported I need to be able to develop, use and test on that platform.

@pgilfernandez
Copy link

Currently there is a small build "issue", as we bundle the gn.bin binary needed to build the engine (skia), macOS will refuse to run it since it's not signed (the old right-click trick still works here). Might need to add instructions on how to build gn from source to avoid the signed issue.

Hi,
I tried by myself to compile and I think I reach the point you commented:

/bin/sh: /Users/pablo/GitHub/friction/src/engine/skia/bin/gn.bin: No such file or directory
FAILED: src/engine/Engine-prefix/src/Engine-stamp/Engine-configure /Users/pablo/GitHub/friction/build/src/engine/Engine-prefix/src/Engine-stamp/Engine-configure 
cd /Users/pablo/GitHub/friction/build/src/engine/skia && /Users/pablo/GitHub/friction/src/engine/skia/bin/gn.bin gen --root=/Users/pablo/GitHub/friction/src/engine/skia /Users/pablo/GitHub/friction/build/src/engine/skia "--args=ar=\"/usr/bin/ar\" cc=\"/usr/bin/clang\" cxx=\"/usr/bin/clang++\" extra_cflags=[\"-Wno-error\", \"-Wno-psabi\"] extra_cflags_cc=[\"-frtti\"] is_official_build=true is_debug=false skia_enable_pdf=false skia_enable_skottie=false skia_enable_tools=false skia_use_dng_sdk=false skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_icu=false skia_use_system_harfbuzz=false skia_use_system_zlib=false skia_use_libgifcodec=false" && /usr/local/Cellar/cmake/3.24.2/bin/cmake -E touch /Users/pablo/GitHub/friction/build/src/engine/Engine-prefix/src/Engine-stamp/Engine-configure
ninja: build stopped: subcommand failed.

I don't know how to continue, I'll wait for your your instructions ;-)

Thanks

@rodlie
Copy link
Member Author

rodlie commented Oct 22, 2024

src/engine/skia/bin/gn.bin should be there, double check that you have the latest commits from branch macos (gn.bin was introduced in 8d4e374).

git pull origin macos && git submodule update -i --recursive

@pgilfernandez
Copy link

It worked, thanks.

Anyway, it failed again:

FAILED: icudtl.dat 
python "/Users/pablo/GitHub/friction/src/engine/skia/gn/cp.py" ../../../../src/engine/skia/third_party/externals/icu/common/icudtl.dat icudtl.dat
/bin/sh: python: command not found
[1498/1508] compile ../../../../src/engine/skia/third_party/externals/harfbuzz/src/hb-subset.cc
ninja: build stopped: subcommand failed.
FAILED: src/engine/Engine-prefix/src/Engine-stamp/Engine-build /Users/pablo/GitHub/friction/build/src/engine/Engine-prefix/src/Engine-stamp/Engine-build 
cd /Users/pablo/GitHub/friction/build/src/engine/skia && ninja -j8 && /usr/local/Cellar/cmake/3.24.2/bin/cmake -E touch /Users/pablo/GitHub/friction/build/src/engine/Engine-prefix/src/Engine-stamp/Engine-build
ninja: build stopped: subcommand failed.

@rodlie
Copy link
Member Author

rodlie commented Oct 22, 2024

https://github.com/friction2d/friction/blob/macos/BUILD.md#requirements-on-macos

python and python3 must be in PATH and point to Python 3.x.

I know this is a bit weird, but skia uses python3 and third-party uses python. This will be resolved at some point.

If you don't want to make a global python shortcut just make a custom dir somewhere and add a python symlink in that folder and add that folder to PATH during build.

rodlie added a commit that referenced this issue Oct 22, 2024
@pgilfernandez
Copy link

I finally was able to compile it!

friction

I got some troubles specifying qscintilla paths but I finally got it working.
If you don't mind I'll PR the BUILD.md file with more detailed instructions so that more brave macOS users try it, is that fine?

@rodlie
Copy link
Member Author

rodlie commented Oct 22, 2024

If you don't mind I'll PR the BUILD.md file with more detailed instructions so that more brave macOS users try it, is that fine?

Sure.


I was able to fix the zoom issue in the canvas (latest commit in macos), at least here (MBA touchpad). Will look into gestures support.

@pgilfernandez
Copy link

Nice!
I'll try it out tomorrow. I was tinkering around and it worked like a charm, I didn't get any error, slowdown or crash. Let me know where I have to look or try to test if it works or not.

@rodlie
Copy link
Member Author

rodlie commented Oct 22, 2024

Major issues seems to have been resolved, there are some minor paper cuts left.

Will try to use my Macbook when I use Friction at work this month, usually the best way to find issues.

@tomgasper
Copy link

tomgasper commented Oct 23, 2024

Also had issues with qscintilla and python paths but managed to solve it and have built the app :)
Screenshot 2024-10-23 at 10 10 45

@rodlie
Copy link
Member Author

rodlie commented Oct 23, 2024

On macports QScintilla is located in the same folder as Qt.

-DQSCINTILLA_LIBRARIES_DIRS=/opt/local/libexec/qt5/lib
-DQSCINTILLA_INCLUDE_DIRS=/opt/local/libexec/qt5/include

Note that ffmpeg newer than 4.2.x will misbehave during render. This is a general issue on all platforms, I believe it's a throw/catch issue somewhere.

@pgilfernandez
Copy link

I compiled using this code:

cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DQSCINTILLA_INCLUDE_DIRS=/opt/local/libexec/qt5/include \
-DQSCINTILLA_LIBRARIES_DIRS=/opt/local/libexec/qt5/lib \
-DQSCINTILLA_LIBRARIES=qscintilla2_qt5 \
..

@rodlie
Copy link
Member Author

rodlie commented Oct 23, 2024

-DCMAKE_INSTALL_PREFIX=/usr
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_COMPILER=clang \

No need, they are for Linux.

-DQSCINTILLA_LIBRARIES=qscintilla2_qt5

This is the default value, not needed.

@rodlie
Copy link
Member Author

rodlie commented Oct 23, 2024

Building supported ffmpeg

Download and extract https://www.ffmpeg.org/releases/ffmpeg-4.2.10.tar.xz

MKJOBS=${MKJOBS:-2}
./configure \
--prefix=/opt/local/ffmpeg42 \
--extra-ldflags=-L/opt/local/lib \
--enable-shared \
--disable-static \
--disable-securetransport \
--disable-audiotoolbox \
--disable-videotoolbox \
--disable-libxcb \
--disable-hwaccels \
--disable-devices \
--disable-openssl \
--disable-sdl2 \
--disable-xlib \
--disable-libxcb \
--disable-libv4l2 \
--disable-alsa \
--disable-network \
--disable-programs \
--disable-debug \
--disable-doc \
--enable-avresample \
--enable-gpl \
--enable-version3 \
--disable-avisynth \
--disable-gnutls \
--disable-libass \
--disable-libbluray \
--disable-libbs2b \
--disable-libcaca \
--enable-libmp3lame \
--disable-libopencore-amrnb \
--disable-libopencore-amrwb \
--disable-libopus \
--disable-libspeex \
--enable-libtheora \
--disable-libvidstab \
--disable-libvo-amrwbenc \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libaom \
--enable-libx265 \
--enable-libxvid
make -j${MKJOBS}
sudo make install

Will build and install to /opt/local/ffmpeg42.

Example release build

CWD=`pwd`
COMMIT=`git rev-parse --short HEAD`

export CC="/usr/bin/clang"
export CXX="/usr/bin/clang++"
export PATH="/opt/local/bin:${PATH}"
export PKG_CONFIG_PATH="/opt/local/ffmpeg42/lib/pkgconfig:/opt/local/lib/pkgconfig:${PKG_CONFIG_PATH}"

QT_DIR="/opt/local/libexec/qt5"
BUILD_DIR=${CWD}/build-release

if [ -d "${BUILD_DIR}" ]; then
    rm -rf ${BUILD_DIR}
fi
mkdir ${BUILD_DIR} && cd ${BUILD_DIR}

cmake -G Ninja \
-DGIT_COMMIT=${COMMIT} \
-DCMAKE_BUILD_TYPE=Release \
-DQSCINTILLA_INCLUDE_DIRS=${QT_DIR}/include \
-DQSCINTILLA_LIBRARIES_DIRS=${QT_DIR}/lib \
${CWD}

cmake --build .

# only needed if you want to use the app on a different machine etc:
${QT_DIR}/bin/macdeployqt src/app/friction.app

I will add scripts etc this week, and maybe a CI builder.

@rodlie rodlie added this to the 1.0.0 milestone Oct 23, 2024
@rodlie
Copy link
Member Author

rodlie commented Oct 25, 2024

The macos branch now has gestures support.

  • Pan (Slide two fingers, alt modifier to zoom)
  • Zoom in or out (Pinch with two fingers)
  • Smart Zoom (Double-tap with two fingers)
    • Fit to size or width

@tomgasper
Copy link

I will definitely play around with Friction on Mac OS soon when I have some extra time. I was thinking about implementing some basic IK system similar to DUIK from After Effects.

@pgilfernandez
Copy link

Talking about the cache problems, let me say something probably stupid, but that I'm saying anyway in case it drops some help in the subject:

Olive Video Editor also used a cache system, I recall they had some troubles with the cache but got it working pretty good. I see both projects use C++, Olive cache system might help you figure out the problems you are facing, maybe just the ones under macOS or maybe not helping at all, but, well, I'm just referring you to them just in case:

https://github.com/olive-editor/olive

Cheers

@rodlie
Copy link
Member Author

rodlie commented Nov 8, 2024

Sorry, but Olive and Friction has completely different code base.

The cache system works just fine on Linux and Windows. This is a specific issue in Friction on macOS (and possible other systems, like the BSDs, but they are unsupported anyway).


I will however take a peek at Olive when I start work on the new color management system (v2+).

@pgilfernandez
Copy link

As you commented here, we are posting all macos related things in this issue:

I tried installing SVGO in macOS without any trouble just using:
npm i -g svgo

Now I use which svgo and it tells me:
/usr/local/bin/svgo

I tried adding it into PATH but I had no luck making it work in Friction, even if you wrote that there is a fallback option to search in your PATH.

I had a look at your code and I have the feeling that the code you wrote for loading SVGO specifies windows or linux but not other SO... am I right? is there anything else I'm missing? maybe it's not possible...

@rodlie
Copy link
Member Author

rodlie commented Nov 11, 2024

The SVGO stuff was added before macOS support, so it's only for Windows and Linux. Should be easy to add support for macOS.

Will look at it later today.

@rodlie
Copy link
Member Author

rodlie commented Nov 11, 2024

Actually, it works fine on macOS here.

I put svgo in /usr/local/bin and Friction uses it.

I added support for svgo-macos in APP PATH as with Windows and Linux, if you have friction.app/Contents/MacOS/svgo-macos it will use that, else fallback to PATH/svgo.

@pgilfernandez
Copy link

Actually, it works fine on macOS here.

I put svgo in /usr/local/bin and Friction uses it.

I added support for svgo-macos in APP PATH as with Windows and Linux, if you have friction.app/Contents/MacOS/svgo-macos it will use that, else fallback to PATH/svgo.

Umm, I may be doing something wrong:

  • I just installed SVGO and I get a file at /usr/local/bin but Friction (with last commit) doesn't find it
  • if I place that file renamed to "svgo-macos" to friction.app/Contents/MacOS/svgo-macos, Friction does find something because it let's me try to export the file with the optimization, but it crashes when I run it:
/Users/pablo/GitHub/friction/build/src/app/friction.app/Contents/MacOS/friction 
Friction 1.0.0-dev - https://friction.graphics
OpenGL Vendor: ATI Technologies Inc.
OpenGL Renderer: AMD Radeon Pro 455 OpenGL Engine
OpenGL Version: 4.1 ATI-4.8.101
---
Entered initializeGpu
OffscreenQGL33c initialized
Make OffscreenQGL33c current
iniPlainVShaderVBO
iniPlainVShaderVAO
iniTexturedVShaderVBO
iniTexturedVShaderVAO
iniColorPrograms
Done OffscreenQGL33c current
Entered GpuExecController initialize
GpuTaskExecutor initialized
Entered GpuTaskExecutor::initializeContext
Created GrGLInterface
Created GrContext
iniTexturedVShaderVAO
SwitchableContext set
Done GpuTaskExecutor::initializeContext
QObject::connect(Property, PropertyBindingBase): invalid nullptr parameter
QObject::connect(Property, PropertyBindingBase): invalid nullptr parameter
QObject::connect(Property, PropertyBindingBase): invalid nullptr parameter
QObject::connect(Property, PropertyBindingBase): invalid nullptr parameter
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'picocolors'
Require stack:
- /Users/pablo/GitHub/friction/build/src/app/friction.app/Contents/MacOS/svgo-macos
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/pablo/GitHub/friction/build/src/app/friction.app/Contents/MacOS/svgo-macos:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/pablo/GitHub/friction/build/src/app/friction.app/Contents/MacOS/svgo-macos'
  ]
}
zsh: segmentation fault

I have the feeling that the problem is because the file I have at /usr/local/bin/svgo is not the right one as it is so small compared with the binaries you have for Windows or Linux... mine is just 288 bytes. Any idea what I'm doing wrong?

Thanks

@rodlie
Copy link
Member Author

rodlie commented Nov 11, 2024

Try this: https://github.com/friction2d/friction-sdk/releases/download/20240915/svgo-macos.zip

@pgilfernandez
Copy link

Try this: https://github.com/friction2d/friction-sdk/releases/download/20240915/svgo-macos.zip

yes! yours works like a charm so I guess there is something wrong with both how I installed SVGO and what file I'm supposed to have as a binary... did you do anything special after installing SVGO at /usr/local/bin?

@rodlie
Copy link
Member Author

rodlie commented Nov 11, 2024

did you do anything special after installing SVGO at /usr/local/bin?

I used the file linked above, tested it as /usr/local/bin/svgo and as friction.app/Contents/MacOS/svgo-macos

svgo-macos is a self contained bundle/app.

I don't use npm, so didn't test that. It should "just work", try running the npm version of svgo from a terminal, does that work?

@pgilfernandez
Copy link

did you do anything special after installing SVGO at /usr/local/bin?

I used the file linked above, tested it as /usr/local/bin/svgo and as friction.app/Contents/MacOS/svgo-macos

svgo-macos is a self contained bundle/app.

I don't use npm, so didn't test that. It should "just work", try running the npm version of svgo from a terminal, does that work?

Tomorrow I'll try to explore it, just to learn as what you provide me solved the problem, that is, your svgo-macos binary works perfectly. Thanks

@pgilfernandez
Copy link

I'm trying #311, great! it works like a charm.
But I have another macOS issue (simple one): the "Markers editor" popup doesn't stays on top... same behavior as happened with the Expressions editor popup so I guess I would have same fix, right?

Thanks!

@rodlie
Copy link
Member Author

rodlie commented Nov 12, 2024

Ok, will fix.

rodlie added a commit that referenced this issue Nov 12, 2024
Add WindowStaysOnTopHint on macOS.

Ref: #272
@rodlie
Copy link
Member Author

rodlie commented Nov 12, 2024

Fixed in d5fa74b

@pgilfernandez
Copy link

Fixed in d5fa74b

Uhh, I just tried and now the popup stays always on top but no matter in what positon the time line is placed that when adding a new marker with the "+" button, it adds it on frame 0... it would be useful that it adds it in current position of time line, right?

Screenshot 2024-11-12 at 22 49 46

@rodlie
Copy link
Member Author

rodlie commented Nov 12, 2024

Yeah, my bad. For some reason I didn't use current frame when adding a new marker through the editor, don't know what I was thinking (was probably not) 😄

Fixed in b271e07

@pgilfernandez
Copy link

Yeah, my bad. For some reason I didn't use current frame when adding a new marker through the editor, don't know what I was thinking (was probably not) 😄

Fixed in b271e07

There is still a remaining "glitch": if you have a marker in frame 0 and add a new one at any other frame with the "+" button of the Marker Editor, it deletes any marker created at frame 0...

@rodlie
Copy link
Member Author

rodlie commented Nov 13, 2024

Yeah, the editor has limited testing (I don't use it) and was added because I knew people would ask for it.

I don't have time to look into the issue until later tonight.

Probably something in https://github.com/friction2d/friction/blob/main/src/ui/widgets/markereditor.cpp#L103

@rodlie
Copy link
Member Author

rodlie commented Dec 16, 2024

Got initial (wip) gesture support in the timeline (e423168)

  • zoom the timeline
  • pan (left/right) timeline

@rodlie
Copy link
Member Author

rodlie commented Dec 16, 2024

🥁 .... We finally got working CI for macOS 🥳

Changes are part of the macos branch that will be merged into main sometime this week.

@rodlie
Copy link
Member Author

rodlie commented Jan 6, 2025

Noticed a major issue on macOS.

I'm currently working on a project on my workstation, not to advanced, but uses 'colorize' effect.

When opening this project on my macbook things start to get weird, the project gets unusable (show/hide on most stuff don't work, raster stuff don't work etc etc). Very odd issue and took some time to figure out the root of the issue.

It seems loading any of the included raster effects except for (m)blur/shadow ends up corrupting the state of the project/Friction.

Reproduce:

  1. Import an image
  2. Add 'colorize' effect
  3. Nothing happens and your project is now bork

@rodlie
Copy link
Member Author

rodlie commented Jan 6, 2025

Found the issue. We replace texture2D with texture in frag files, this breaks some shaders.

@rodlie
Copy link
Member Author

rodlie commented Jan 6, 2025

@pgilfernandez
Copy link

Arrived late to this...

Is it now fixed or needs further testing?

@rodlie
Copy link
Member Author

rodlie commented Jan 7, 2025

I only tested on macOS (Intel GPU), should work fine on other platforms and gfx cards.

macOS is more strict regarding OpenGL, so anything deprecated in OpenGL 3.3 must be fixed.

I will test #410 on Linux and Windows with NVIDIA/Intel GPUs before merging. Any card/driver not working with this fix should be considered unsupported anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@pgilfernandez @rodlie @tomgasper and others