-
Notifications
You must be signed in to change notification settings - Fork 18
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
Universal (x86/arm64) launcher for Mac OS #82
Comments
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-clij-etc-native-on-apple-silicon-arm64-m1/53627/16 |
Thinking about it more, this is a regression, since being able to run Fiji in Rosetta can certainly be desired—especially in the early going, ie. now. |
@psobolewskiPhD I want to thank you for all your efforts in this direction, and apologize for my silence till now. Another user asked on in the fiji Gitter chat room about running Fiji on M1, so I linked them to this very helpful issue. 😄 |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-clij-etc-native-on-apple-silicon-arm64-m1/53627/24 |
Hey Peter, thanks for your work on this, it'll only become more important as more M1 Macs are adopted in the bioimaging community. My issue is that, while I can manage to compile the launcher into an ARM executable that runs, imagej-launcher itself seems to be incompatible with modern versions of the JDK, both the official ARM-native Oracle JDK17 (https://www.oracle.com/java/technologies/downloads/#jdk17-mac), and OpenJDK from a package manager like Homebrew. The error is Required service is missing: net.imagej.legacy.LegacyService, preventing Fiji/ImageJ from launching. The issue seems to have come up before in discussions related to Java 9 and 10 in this repository. We could just stick to this Azul JDK, but I'm curious to know:
|
I've only used (and still using) Azul Java 11. |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/could-not-install-fiji-on-mac-os-monterey-can-any-one-help-thanks/63880/13 |
@psobolewskiPhD This is fantastic.
Did you get a chance to try this out? (with the "official" x86 azul java 8 JRE) If that works then I am in favor of merging this and building new bundles. |
Sorry an x86 mac isn't conveniently available at the moment. |
@psobolewskiPhD just had someone locally test the launcher on an |
The only catch is I think it won't work on M1 wanting to run x86 in Rosetta.
Seems like the FAT binary defaults to native if possible which then clashes with the Java. So maybe the x86 Java bundle should have x86 launcher. But the no-JRE bundle could have the FAT launcher? And a putative arm64 Java bundle could have FAT too. |
@psobolewskiPhD would you mind testing one more bundle? This should have your
I don't have a sense of how big an issue this might be - why would they want to do this? They would still have the option to just use the |
Your new bundle is wierd? I don't get it. I get system Java when double click and the main menu is ImageJ (not Fiji) and About ImageJ gives just I will download a fresh no-JRE and try transplanting the zulu +/- a fresh zulu zip. Edit: Yeah I can't figure it out. Same behavior. Why would double click be different than ./Imagej-launcher? Edit2: it has to be something with the Contents/Info.plist
See: https://developer.apple.com/documentation/bundleresources/information_property_list/lsarchitecturepriority
I think it comes down to plugins. Basically, anything with a compiled dependency that hasn't setup an arm64 version will not run in an arm64 Fiji. It's all or nothing: all emulated by Rosetta2 (which btw, excludes AVX instructions) or all native arm64. |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/could-not-install-fiji-on-mac-os-monterey-can-any-one-help-thanks/63880/14 |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-bundles-updated-with-newest-zulu-8-jdk-fx/65809/7 |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-bundles-updated-with-newest-zulu-8-jdk-fx/65809/11 |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/how-to-get-fiji-to-run-natively-on-macos-m1-arm64-apple-silicon/68384/2 |
Sure. |
@psobolewskiPhD Thanks. You don't even need to run CMake directly; just run |
I'm starting to wonder if having a universal launcher is a good idea. Does that mean we will need to make dual-arch fat binaries for everything? I think we should figure out how to have distinct launchers for the Intel and the Apple M processors as soon as possible. |
What's the advantage of distinct launchers vs a universal binary? I think a plan for moving to support M1 in general is a good idea. It will make it easier to find bugs, report stuff, etc. Cross compiling in most cases isn't hard, so just getting eye balls on stuff that needs some attention seems like a win to me, but I'm obviously biased since I have an M1. |
The launcher is only the beginning. There are more native components that need M1 support. Are we going to be put into a situation where we need to make other native components universal as well? I think the answer to this is yes, although I'm not sure if it necessarily applies to everything. If the answer is yes, then are upstream suppliers of binaries doing the same or will we need to repackage them? Looking at the homebrew discussion, it's pretty clear that they are not going to support universal binaries: Homebrew/brew#10307 Based on the last time Apple switched processor architectures, there will come a time when we will want to drop or otherwise deprioritize Intel macOS support. Apple also dropped support for universal binaries at some point before reestablishing it for the current architecture change. How will distributing a universal binary affect our ability to split the binaries and prioritize one over the other in the future? The question I'm asking is what kind of technical debt are we taking on by choosing to distribute a universal binary as opposed to treating aarch64-macOS as a distinct platform now rather than later? |
I don't think it does. We can have a fat launcher, but keep the other native libs in |
I don't think they ever disabled running the old Universal binaries (PPC/x86)--there are plenty in the Fiji bundle. I think more likely Apple will stop supporting Rosetta2 at some point. |
While universal mach-o binaries with PowerPC support still technically work, they became impractical at some point since new software needed to adapt for recent versions of Mac OS X which did not run on PowerPC. Let's say a user downloads a FIJI bundle with a universal launcher. Suppose then Apple completely stops releasing new versions of macOS for Intel in three years. Perhaps a year or two after that, we find that we cannot support both recent macOS and legacy macOS with the same code as happened after the PowerPC transition. Do subsequent versions of the universal launcher contain a build with new code for the M9 processor and an a build for Intel processors using older code? At that point, how can we update the universal launcher? The problem I am anticipating is that the use of a FIJI install will exceed Apple's transition period. At the end of that transition period, we may have an issue updating users from a universal binary to a platform specific one when the technical need arises. Perhaps the solution is to give the universal launcher a unique name that clearly identifies what it is. Maybe one of the following.
This would be in anticipation of possibly needing a The immediate practical question for me is what do I with |
I'll weigh in as a more of a user and less a developer-- even though I know I should defer to the people doing the real work here!
|
There is a point where Apple stops supporting Intel Macs, just as they stopped supporting PowerPC Macs. After that, Apple offers no guarantee that this will continue to work. We already have enough issues with code signing as is.
What makes FIJI unique is that we support the software over a very long period of time. A new install now could still be in use in five years or even ten. The problem is that we could not just stop shipping Intel support for a binary called "ImageJ-macosx". If we auto-updated that binary without Intel support, we would break FIJI for people who are still using Intel Macs. Currently, we still have a ImageJ-macosx-tiger in the bundles. Why is that? Basically, I'm asking the question now about the future support plans to make sure we have an easy path forward in several years. |
Not on macOS, unfortunately. Apple virtually guarantees that with their strategy of decisions to intentionally obsolete old hardware and software. Any scientist who buys and uses a Mac needs to be aware of this. Major example: the Java 6 version of Fiji can no longer run on macOS, because Apple Java 6 no longer works, because they don't maintain it, and it makes use of old deprecated+broken native APIs. To clarify though, I'm not disagreeing with you @mkitti. I share your desire to make Fiji work for as long as possible on macOS. But only within the compatibility restrictions imposed by Apple. The good thing is that we also try to make old scripts and plugins continue to work in new downloads of Fiji. So even if a macOS user's Fiji stops working when they update their hardware and/or software, a project goal is for it to be straightforward for them to install a new Fiji that does work on that hardware+software, including all their old scripts, customizations, etc.
Until now, Fiji has been a so-called portable application, meaning you can have a single The switch to M1/ARM has endangered this, because we cannot have If the time comes when we can no longer build a universal launcher for all architectures running macOS, then we are already sunk, because we will need to ship a different
Because I am afraid to remove it, in case it still benefits anyone in the wild. |
Is this implemented? Because in my tests Java version is chosen alphabetically... |
@psobolewskiPhD It is implemented in the sense that Linux x86-64 looks in subfolders of |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-for-apple-silicon-macs/80794/2 |
I've been using Fiji on an Apple Silicon M1 (arm64) MacBook Pro (Big Sur 11.4)
I've started a image.sc thread regarding getting things to work smoothly native rather than in Rosetta emulation.
https://forum.image.sc/t/fiji-clij-etc-native-on-apple-silicon-arm64-m1/53627/16
Everything works when architectures are matched, so everything emulated or everything native. Mixing architectures is a no go.
So for Fiji/imagej the key is native JRE. I have Azul 11, but native OpenJDK is also available via homebrew, and use of the "No JRE" Fiji. (The normal Mac OS install also works fine in Rosetta, but is markedly slower.)
The existing launcher actually works—despite being x86.
It does report an architecture mismatch error and does a fallback to system Java, which results in a 2nd Fiji icon in the dock—minor inconvenience.
As noted in the thread, Apple docs show you can build for a different architecture than you run (can't test obviously) and can build universal binaries. This is also supported by cmake, which I was pleased to see is used by the imagej-launcher.
I made a fork (https://github.com/psobolewskiPhD/imagej-launcher) and tweaked CMakeLists.txt to provide the two arch for cmake (to make a universal binary). I also had some Java path issues, which may be a Big Sur thing.
The project compiled with no issue and the binary is universal:
~/dev/imagej-launcher > lipo -info ImageJ-macosx
Architectures in the fat file: ImageJ-macosx are: x86_64 arm64`
I've tested this binary on my Apple Silicon M1 Mac. It works fine with the following behavior when launched from the command line to monitor errors (there's some warnings too regarding patcher/injector, but they seem of no issue):
Launches Fiji via Rosetta, no issues
Launches Fiji after fallback to System Java. No issues. (~5s launch)
Wrong architecture error, system Java fallback, launches Fiji, No issues. (~5s launch)
Wrong architecture error, system Java fallback, launches Fiji, No issues. (<4 s launch)
System Java fallback, launches Fiji, No issues. (<4 s launch)
Normal launch (<4 s), no issues, 1 Fiji in dock
(Also, if anyone is curious, if you put both an x86 and arm64 JRE in Fiji.app/java it's alphabetical. So adoptopen vs zulu results in wrong architecture error and system java. While adoptopen vs 1_zulu uses the included zulu.)
So from where I sit, a universal imagej-macosx for Fiji with native JRE inside is the best for Apple Silicon Macs, but all cases work fine, as long as a system Java exists.
The missing case is universal launcher on x86 Mac, which I might be able to try this weekend.
Here's a link to the binary if anyone wants to test it themselves, it belongs in:
Fiji.app/Contents/macos
https://www.dropbox.com/s/1ftxheyx85siko3/ImageJ-macosx.zip?dl=0
The text was updated successfully, but these errors were encountered: