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

Update MacOS support #382

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Update MacOS support #382

merged 3 commits into from
Oct 18, 2023

Conversation

SFAntti
Copy link

@SFAntti SFAntti commented Sep 9, 2023

Based on the changes from macos branch (#195), but updated against the latest changes in main.

I could not get STB working, so just supporting ISPC (like the original PR). Setting dds compressor to something else than ispc now fails a diagnostics check on Mac.

@avroliner
Copy link

Do we have access to a version 6.0 macos branch?

@SFAntti
Copy link
Author

SFAntti commented Sep 14, 2023

Yes, these changes are based on the current head (5690d7f) of kubilus1/main branch and add on top of that changes from the original macOS branch + some additional changes I needed to make it run.

You can clone my fork from https://github.com/SFAntti/autoortho/ and try it out.

It is working on my M1 MacBook Pro running Ventura 13.5.2

Copy link

@xpcyl8 xpcyl8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried applying changes in this PR against current main and can confirm these changes allowed AO to run on Apple Silicon macs! aside from that python crash which zacklipton found workaround by forcing an older build target for tcl-tk so it used an older call. It is working on my M2 macStudio running Ventura 13.5.2.

@SFAntti
Copy link
Author

SFAntti commented Sep 17, 2023

@kubilus1 , any chance for merging these to your branch? It would be easier to keep them up-to-date there. I'm happy to volunteer for macOS arm testing for future releases (with some time constraints).

@neymarjr410
Copy link

@SFAntti hello im a mac user using macbook pro m1, and ive downloaded your clone of auto ortho, i have managed to open the application however whenever I try to run the program, im always stuck on a step “aoimage/aoimage.dylib” if anyone can help me it’ll be much much appreciated 😭🙏🏻 ive been dealing with this for the past two weeks and not much progress.

also do you have discord etc to contact you directly?

@SFAntti
Copy link
Author

SFAntti commented Oct 14, 2023

im always stuck on a step “aoimage/aoimage.dylib”

What do you mean by being stuck in “aoimage/aoimage.dylib” ? Do you have a screenshot?

@neymarjr410
Copy link

im always stuck on a step “aoimage/aoimage.dylib”

What do you mean by being stuck in “aoimage/aoimage.dylib” ? Do you have a screenshot?
yes i have a screenshot, here:

Screenshot 2023-10-15 at 12 54 22 PM Screenshot 2023-10-15 at 12 55 04 PM

@SFAntti do you have discord where i can message you directly please?

@SFAntti
Copy link
Author

SFAntti commented Oct 15, 2023

@neymarjr410 , I don't have a discord.

Looks like there is an issue loading the jpeg-turbo library. You can try installing it with homebrew (brew reinstall jpeg-turbo).

If it still fails after this I'd try recompiling the aoimage.dylib:

  1. Update JPGT and CFLAGS with the right path to your local jpeg-turbo library and include headers in autoortho/aoimage/Makefile.osx
  2. make -f Makefile.osx

@neymarjr410
Copy link

hi @SFAntti how exactly do i run the command "make -f makefile.osx" in terminal, also do you have any idea save changes and exit after editing tcl-tk through brew on terminal?
image
im currently following these steps on x plane.org https://forums.x-plane.org/index.php?/forums/topic/290387-auto-ortho-for-mac/&page=2, but it doesnt mention makefile so can you further explain the instructions about the make file command.

also, do you have a email i can message directly instead of commenting here, so we can save up a bit of time, sorry to be bothering you as ive been trying to make AO work for the past month already but no signs of success, other than getting the UI working.

@SFAntti
Copy link
Author

SFAntti commented Oct 16, 2023

@neymarjr410 , In general I don't think you'd need to run the makefile unless you need to completely recompile the aoimage.dylib library. Currently the one in my fork is only compiled for arm64, so if you were running on Intel Mac it would not work. However, sounds like you are on arm.

So, the earlier error looks like it can't find the dynamically linked libturbojpeg in various locations in your filesystem: '/opt/homebrew/opt/jpeg-turbo/lib/libturbojpeg.0.dylib' (no suc h file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/jpeg-turbo/lib/1 ibturbojpeg.0.dylib' (no such file), '/opt/homebrew/opt/jpeg-turbo/lib/libturboj peg.0.dylib' (no such file), '/usr/lib/libturbojpeg.0.dylib'.

Did you install brew install jpeg-turbo? If so, can you see where it was installed. If it is installed, but not in one of those locations, you could try creating a symbolic link to one of the paths above it is being searched for.

For example (first make sure the directory /opt/homebrew/opt/jpeg-turbo/lib/ exists or create it):
ln -s <path to your local libturbojpeg.0.dylib> /opt/homebrew/opt/jpeg-turbo/lib/libturbojpeg.0.dylib.

Hope this helps.

@neymarjr410
Copy link

hi @SFAntti i did install jpeg-turbo around an hour ago, but now i dont know why im struggling to find the path to it, i think its because i quitted terminal after finishing all the commands just now, also im on arm64 m1. do you have to redo all the commands ie install turbo jpeg-turbo, brew edit tcl-tk, pip install etc everytime you start AO? because im not sure if i need to redo all the commands in terminal before starting AO every time.

@kubilus1
Copy link
Owner

@neymarjr410 , In general I don't think you'd need to run the makefile unless you need to completely recompile the aoimage.dylib library. Currently the one in my fork is only compiled for arm64, so if you were running on Intel Mac it would not work. However, sounds like you are on arm.

So, the earlier error looks like it can't find the dynamically linked libturbojpeg in various locations in your filesystem: '/opt/homebrew/opt/jpeg-turbo/lib/libturbojpeg.0.dylib' (no suc h file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/jpeg-turbo/lib/1 ibturbojpeg.0.dylib' (no such file), '/opt/homebrew/opt/jpeg-turbo/lib/libturboj peg.0.dylib' (no such file), '/usr/lib/libturbojpeg.0.dylib'.

Did you install brew install jpeg-turbo? If so, can you see where it was installed. If it is installed, but not in one of those locations, you could try creating a symbolic link to one of the paths above it is being searched for.

For example (first make sure the directory /opt/homebrew/opt/jpeg-turbo/lib/ exists or create it): ln -s <path to your local libturbojpeg.0.dylib> /opt/homebrew/opt/jpeg-turbo/lib/libturbojpeg.0.dylib.

Hope this helps.

Thanks for the awesome work for Mac support. Circling back around to this now. I think the real trick is the ispc lib build. Do you know if it's possible to build a lib that would work for arm and x86? Otherwise I'll want to figure out a way to choose both depending on the running system.

@kubilus1
Copy link
Owner

Hi @kubilus1 are u able to build a version specifically for mac users please, because many mac users on this are also having issues with running auto ortho so it would be most ideal if you can provide us some help and come up with a mac version of auto ortho if possible please

I don't really use Mac and only really have an old x86 macbook, so can't build or test ARM stuff. At least not at the moment. I'm also not really the best person to ask about how to make things work on mac or not. I do hope to have an all in one bin like the Linux ver at some point though.

@SFAntti
Copy link
Author

SFAntti commented Oct 17, 2023

I think the real trick is the ispc lib build. Do you know if it's possible to build a lib that would work for arm and x86? Otherwise I'll want to figure out a way to choose both depending on the running system.

I haven't looked into ispc lib much. I'll take another look if I can find one.

Also, in my PR the aoimage.dylib is compiled for arm64 only. It should be possible to cross compile for universal library that works for both x86 & arm64 Macs. I'll update the PR with that.

@kubilus1
Copy link
Owner

I think the real trick is the ispc lib build. Do you know if it's possible to build a lib that would work for arm and x86? Otherwise I'll want to figure out a way to choose both depending on the running system.

I haven't looked into ispc lib much. I'll take another look if I can find one.

Also, in my PR the aoimage.dylib is compiled for arm64 only. It should be possible to cross compile for universal library that works for both x86 & arm64 Macs. I'll update the PR with that.

Ah yeah you are right, both require compilation. I think I already setup libispc_texcomp.dylib for both archs:

$ file libispc_texcomp.dylib
libispc_texcomp.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit x86_64 dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|BINDS_TO_WEAK|NO_REEXPORTED_DYLIBS>] [arm64:Mach-O 64-bit arm64 dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|BINDS_TO_WEAK|NO_REEXPORTED_DYLIBS>]

If aoimage.dylib was also cross arch, I think this would be pretty close to ready to wrap up. Prior iterations of nuitka, which is what packages the bins had issues creating working macos bins, but I'm trying newer versions to see if that's resolved.

@SFAntti
Copy link
Author

SFAntti commented Oct 18, 2023

@kubilus1 , you are right, the libispc_texcomp.dylib was already compiled for both architectures. It was the libstbdxt.dylib that I had had issues with earlier. Looks like it is compiled for arm64 (and I'm on an arm Mac).

I'll give that a try and will update the PR with cross compiled x86 & arm64 aoimage.dylib

@neymarjr410
Copy link

@SFAntti hi bro can you help me out please, i came across this issue while trying to run AO

Wrote config file: /Users/School/.autoortho
Config file found /Users/School/.autoortho reading...
Found sceneries: ['z_ao_aus_pac']
[{'root': '/Volumes/USB DRIVE/SteamLibrary/steamapps/common/X-Plane 11/Custom Scenery/z_autoortho/scenery/z_ao_aus_pac', 'mount': '/Volumes/USB DRIVE/SteamLibrary/steamapps/common/X-Plane 11/Custom Scenery/z_ao_aus_pac'}]
Exiting ...
LIBFUSE: 4413897296 : <CDLL '/usr/local/lib/libfuse.dylib', handle a29d9c10 at 0x10716ba50>

@SFAntti
Copy link
Author

SFAntti commented Oct 18, 2023

@neymarjr410 I'm sorry, but I'm not sure what is the problem in your case. Perhaps something is not working with macFUSE. There was a step you had to give permission to macFUSE kernel extension in Mac. Did you need to do something like that?

@SFAntti
Copy link
Author

SFAntti commented Oct 18, 2023

Updated with arm64 + x86 aoimage.dylib.

@SFAntti
Copy link
Author

SFAntti commented Oct 18, 2023

@kubilus1 , So, I tried running again with the libstbdxt.dylib you've provided (compiled for army64 which is good for my system).

When X-Plane starts to load sceneries and the first call to _stb.compress_pixels(...) happens I get an exception thrown:

WARNING:pydds:dds compress failed
ERROR:fuse:Uncaught exception from FUSE operation read, returning errno.EINVAL.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/refuse/high.py", line 863, in _wrapper
    return func(*args, **kwargs) or 0
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/refuse/high.py", line 974, in read
    ret = self.operations('read', self._decode_optional_path(path), size,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/refuse/high.py", line 1222, in __call__
    return getattr(self, op)(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/<user>/src/test-new-auto/test-own-auto/autoortho/autoortho/autoortho_fuse.py", line 384, in read
    data = t.read_dds_bytes(offset, length)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/<user>/src/test-new-auto/test-own-auto/autoortho/autoortho/getortho.py", line 606, in read_dds_bytes
    self.get_bytes(0, length)
  File "/Users/<user>/src/test-new-auto/test-own-auto/autoortho/autoortho/getortho.py", line 572, in get_bytes
    self.dds.gen_mipmaps(new_im, mipmap, mipmap, compress_len)
  File "/Users/<user>/src/test-new-auto/test-own-auto/autoortho/autoortho/pydds.py", line 537, in gen_mipmaps
    if dxtdata is not None:

I wonder if it's something odd with arm64 and the python ctype mapping. How did you build the library, or where did you get it from?

Anyway, using ISPC does work, so perhaps we could try to solve the stb as a separate change.

@kubilus1
Copy link
Owner

@kubilus1 , So, I tried running again with the libstbdxt.dylib you've provided (compiled for army64 which is good for my system).
Anyway, using ISPC does work, so perhaps we could try to solve the stb as a separate change.

Yeah i wouldn't worry much about STB since it's an older DDS compression mechanism that's worse the ISPC in most ways.

@kubilus1
Copy link
Owner

I think there is a bit of divergence between this and the original macos branch I started. I'll look into straightening out the merges ...

@kubilus1 kubilus1 changed the base branch from main to macos_prmerge October 18, 2023 14:24
@kubilus1 kubilus1 merged commit f2a3257 into kubilus1:macos_prmerge Oct 18, 2023
@SFAntti
Copy link
Author

SFAntti commented Oct 18, 2023

I think there is a bit of divergence between this and the original macos branch I started. I'll look into straightening out the merges ...

Ok, thank you! If needed I can help validate locally.

@neymarjr410
Copy link

neymarjr410 commented Oct 21, 2023

@neymarjr410 I'm sorry, but I'm not sure what is the problem in your case. Perhaps something is not working with macFUSE. There was a step you had to give permission to macFUSE kernel extension in Mac. Did you need to do something like that?

hi @SFAntti yeah i gave permission in privacy & security, and which rebooted my mac, but it still says whenever i try to run AO

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

Successfully merging this pull request may close these issues.

5 participants