3Dickulus / FragM

Derived from https://github.com/Syntopia/Fragmentarium/
GNU General Public License v3.0
353 stars 30 forks source link

Crashes at startup on mac os mojave :( #40

Closed shengsword closed 5 years ago

shengsword commented 5 years ago

Process: Fragmentarium-2.5.0 [4672] Path: /Users/USER/*/Fragmentarium-2.5.0.app/Contents/MacOS/Fragmentarium-2.5.0 Identifier: ??? Version: ??? (???) Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: Fragmentarium-2.5.0 [4672] User ID: 501

Date/Time: 2019-04-15 22:29:09.969 +0800 OS Version: Mac OS X 10.14.3 (18D109) Report Version: 12 Anonymous UUID: E6764C73-510D-FD71-76CD-3F74154FAF56

Time Awake Since Boot: 2200 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGABRT) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000050 Exception Note: EXC_CORPSE_NOTIFY

shengsword commented 5 years ago

My cmake config:

Screen Shot 2019-04-15 at 22 34 25
3Dickulus commented 5 years ago

Yes, it will always crash on Mac until Mac supports QSurfaceFormat::CompatibilityProfile or until I can figure out how to get FragM to run under core profile.

The code of interest is DisplayWidget.h line 95 class DisplayWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_1_Compatibility and DisplayWidget.cpp line 32 fmt.setProfile(QSurfaceFormat::CompatibilityProfile);

I don't have a Mac so if you want to try playing with these lines I would be most interested in the results. If you change "Compatibility" to "Core" in the above mentioned lines I don't think it will compile?

The stacktrace is virtually useless in this case.

3Dickulus commented 5 years ago

ohoh my mistake (after updates) it will compile and run using Core profile but I get a blank GL area ???

shengsword commented 5 years ago

I changed it to fmt.setProfile(QSurfaceFormat::CoreProfile); It compiled ok but still crashed when it running the stacktrace is almost the same... wired

3Dickulus commented 5 years ago

Did you change the line in DisplayWidget.h file as well ?

shengsword commented 5 years ago

sorry, my mistake I lost it ... Yeh! the app could be launched normally but shader compiled fail: Could not create vertex shader: ERROR: 0:1: '' : #version required and missing. ERROR: 0:11: 'varying' : syntax error: syntax error We changed it to core profile(OpenGL4.1), but the shaders are only supported with OpenGL2.0 thanks @3Dickulus for the quick help

shengsword commented 5 years ago

@3Dickulus thanks 👍 It works now! Let me summarize it:

  1. DisplayWidget.cpp line 32 fmt.setProfile(QSurfaceFormat::CoreProfile);
  2. DisplayWidget.h line 95 class DisplayWidget : public QOpenGLWidget, protected QOpenGLFunctions
  3. Change the include path in "preferences" to the example include path

Doing the 3 steps above makes the application runs normally except the retina display problem

  1. Modify the info.plist in "Fragmentarium-2.5.0.app" by adding the following 4 lines: <key>NSPrincipalClass</key> <string>NSApplication</string> <key>NSHighResolutionCapable</key> <string>True</string> in the \<dict> section
  2. Copy "Fragmentarium-2.5.0.app" to different location after Info.plist update (since MacOS cache all .plist files and without that update will not be apply)

And then run Fragmentarium, it should have the retina display... have fun : )

3Dickulus commented 5 years ago

Awesome!!!

It won't compile here (linux) unless DisplayWidget.h line 95 is ... class DisplayWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_1_Core

fails on double types like glUniform1d etc...

I will add some #ifdefined Q_OS_MAC statements and see how it does on the travis build system, will also add notes about Info.plist file, where is that file? is it made by MacOS or by app deployment package?

If you can help with testing a Mac deployment package that would be great!

shengsword commented 5 years ago

Info.plist file, where is that file? is it made by MacOS or by app deployment package?

Yes, inside Fragmentarium-2.5.0.app (the deployed package is actually a folder on MacOS) more info: https://doc.qt.io/qt-5/highdpi.html

Changing to QOpengGLFunctions_4_1_Core leads the shaders not compiled? (since the shaders are written in GLSL #130 syntax)

I'd like to do the test : )

3Dickulus commented 5 years ago

So it would seem that for Mac Qt has "pseudo" compatibility profile ability? I didn't find in the docs?

I have a very tight schedule this weekend, Easter + visiting family etc... so I won't be able to do much with this, I will push Q_OS_MAC patch shortly that implements 1. and 2. above but in 3. I assume you have an absolute path? it would be better as a relative path, can you test these relative paths ? ./Examples/Include ../Examples/Include ../../Examples/Include if one of these doesn't work then I will add a request dialog to set the path if includes are not found... or something like that.

also you can find shell script and fqs script files here https://fractalforums.org/fragmentarium/17/fragm-2-5-0/1974/45#msg13687 that will automatically test all frags in examples folder by rendering a thumbnail of each and saving png files in ./test folder, you may have to make some adjustments to the shell script but the fqs script should be OS independant

shengsword commented 5 years ago

Yep I make it an absolute path. The working path seems to be Framentarium-2.5.0.app/Contents/MacOS/ thus it depends where the Framentarium-2.5.0.app in... If I put the app inside the folder where the Examples Folder in, then the relative path should be ../../../Examples/Include

3Dickulus commented 5 years ago

I went through this process, compiling on mac, with user bermarte some time ago, Qt now provides deployment tools for Lin Win and OSX so I'm going over the .travis.yml file and comparing with https://doc.qt.io/qt-5.9/osx-deployment.html#the-mac-deployment-tool . I would like to provide working binary packages for all

Currently the osx stuff is commented out and needs some updating to match changes at travis-ci.org

3Dickulus commented 5 years ago

Managed to get a linux AppImage built, I thought it would be best to try linuxdeployqt before macdeployqt to figure out the process >:-P The only problem is the Examples/ folder is in the image, it loads ok but not sure about a few things like saving files and what happens when users want to edit raytracer or other support frags.

When running an app from a mac appimage (dmg file?) can the app save or change things in the image? or will there have to be a "userland" copy of the Examples/ folder ???

3Dickulus commented 5 years ago

Could not create vertex shader: ERROR: 0:1: '' : #version required and missing. ERROR: 0:11: 'varying' : syntax error: syntax error

Some builtin frag compilers provided by the drivers require #version statements as the first line in the frag code, minimum for FragM is #version 110

shengsword commented 5 years ago

sorry for the delay...

When running an app from a mac appimage (dmg file?) can the app save or change things in the image? or will there have to be a "userland" copy of the Examples/ folder ??? changing or saving things

.dmg file is the install-package, when it is installed, it should generate the .app (actually a folder which can open it normally) Actually, I dragged the Example folder inside the Fragmentarium-2.5.0.app, and then I can resolve the include path to be just: Examples/Include.

Screen Shot 2019-04-21 at 22 11 39

As u can see in the image, I can save files (sssssssss.frag) inside the app folder, when running Fragmentarium

3Dickulus commented 5 years ago

Ok that works :) I had to do something similar for the linux appimage by making the install root appdir/usr/bin/ . This installs the executable and all support files in the bin folder :P

I'm following https://doc.qt.io/qt-5.9/osx-deployment.html

3Dickulus commented 5 years ago

ok finally got an appdir bundle made ... check https://github.com/3Dickulus/FragM/releases

Operating System Details ProductName: Mac OS X ProductVersion: 10.13.3 BuildVersion: 17D102

Fragmentarium-2.5.0-190419-osx.zip contains Screenshot_20190422_002949

will this run on 10.14 ? I really don't want to have to make a package for every flavour of OSX

shengsword commented 5 years ago

I tried the appimage on 10.14.3, it could be launched normally. however when building a shader, it reports the shader-version error:

Screen Shot 2019-04-23 at 08 18 36
3Dickulus commented 5 years ago

try adding in the editor as the first line in the fragment source code... #version 120 and/or check Edit->Preferences->Include path as referenced above?

shengsword commented 5 years ago

and/or check Edit->Preferences->Include path as referenced above?

The include path now is "/Include/Example. should be Include/Example instead to make it work.

changing to #version 120 still reports error: "version 120 is not supported" :(

3Dickulus commented 5 years ago

ok, in core profile I think the minimum is GL 3.2 and GLSL 150 while GL core 4.1 requires GLSL 410 but it worked and rendered before (as above) ? with no #version statement ?

aha! found this https://github.com/arl/macdeployqtfix aparently there is one more step to finish the job >:-p it could be that the executable just can't find everything it needs ?

if you have Qt SDK installed on your system you should also have macdeployqt and could use macdeployqtfix

build as normal using cmake and make install... these are the commands I use on a clean mac environment... (one after another in a console starting in folder where FragM lives)

  brew install qt5
  brew install ilmbase openexr
  brew unlink openexr
  brew link --overwrite openexr
  brew unlink ilmbase
  brew link --overwrite ilmbase
  brew unlink cmake
  brew install cmake

make sure these paths are set

  export QTDIR="/usr/local/opt/qt"
  export PATH="/usr/local/opt/qt/bin:$PATH"
  export LDFLAGS="-L/usr/local/opt/qt/lib"
  export CPPFLAGS="-I/usr/local/opt/qt/include"
  export PKG_CONFIG_PATH="/usr/local/opt/qt/lib/pkgconfig"

  cd FragM
  mkdir Fragmentarium-Source/build
  cd Fragmentarium-Source/build
  cmake -DUSE_OPEN_EXR=ON -DCMAKE_INSTALL_PREFIX=../../ ..

   make install

   cd ../../Fragmentarium-2.5.0

^^^ this is where make install puts the appdir then I mv everything to where it needs to be although maybe should leave these where make install puts them ? I don't have a mac to play with so I can only speculate :-/

   mv ./Examples ./Fragmentarium-2.5.0.app/Contents/MacOS/Examples
   mv ./fqScript ./Fragmentarium-2.5.0.app/Contents/MacOS/fqScript
   mv ./Misc ./Fragmentarium-2.5.0.app/Contents/MacOS/Misc
   mv ./Languages ./Fragmentarium-2.5.0.app/Contents/MacOS/Languages

   macdeployqt ./Fragmentarium-2.5.0.app
   macdeployqtfix ./Fragmentarium-2.5.0.app/Contents/MacOS/Fragmentarium-2.5.0.app $QTDIR

^^^ this is where macdeployqtfix goes

have a look at the macdeployqtfix page for further insight, it's a python script. If you can do this and share your findings there are some other mac users will be greatful :) I won't be able to do much until this weekend so no rush, this is, after all, just a hobby ;)

3Dickulus commented 5 years ago

The include path now is "/Include/Example. should be Include/Example instead to make it work.

unless I have misunderstood and it is working ???

shengsword commented 5 years ago

I mean, changing the include path to "Include/Example" makes the shader header files to be found :)

3Dickulus commented 5 years ago

hm, in MainWindow.cpp line 2479...

examplesDir << "Examples" << "../Examples" << "../../Examples" << "../../../Examples";

should maybe have ./ in front of the first "Examples" ?

ok, so it can find everything just won't compile and run fragments? but it did, so what's different now?

3Dickulus commented 5 years ago

I did add...

<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>

...to the file Fragmentarium-2.5.0.app/Contents/Info.plist

shengsword commented 5 years ago

ok, so it can find everything just won't compile and run fragments?

yes , headers could be found, but just running shader error ("version problem above")

the only difference is just the shader error ....

it wired, the package I built from the source has no problem...

3Dickulus commented 5 years ago

ok sounds like something in the Qt GL libs is not getting set properly, pure OSX core profile vs Qt special profile, in a couple of days I will have some time to poke at this, I will build another one using macdeployqtfix

I have set core profile with include deprecated functions, this is not the same as compatibility profile but if you compiled a working executable from the sources it must be possible on Travis build service too. I am using their defaults for OS image and environment, Xcode 9.4.1 | macOS 10.13 | JDK 10.0.1 For OS version compatibility I'm not sure if I should use the oldest version or newest ?

3Dickulus commented 5 years ago

Right! found some time for a quick OSX build, check in releases :) macdeployqtfix ran successfully, there were a lot of warns during compile about deprecated GL functions but no errors.

shengsword commented 5 years ago

@3Dickulus

the same shader version error : ( I tested the mac at my home and another mac at my work, the same shader error....

And the post can help something? glsl version error Maybe i will try another mac from my colleague tomorrow...

3Dickulus commented 5 years ago

I don't think another mac will behave any differently than yours :(

re:And the post can help something? Not really, as I said I don't have a mac to play with. I think I've mentioned those facts about GL3.2 and no compatibility profile on mac and Qt's way of handing back a context.

Can you go back and replicate the steps you outlined above that worked?

Did you keep a copy of the working code and executable?

shengsword commented 5 years ago

@3Dickulus sorry for the late response... I have rebuilt it on two macs, one of them is the brand new ... The two macs all succeeded with the outlined steps above...

Screen Shot 2019-05-05 at 11 43 25 PM
3Dickulus commented 5 years ago

I'm wondering if it needs a real mac to build on and the travis-ci emulation is not quite right... so

  1. DisplayWidget.cpp line 32 fmt.setProfile(QSurfaceFormat::CoreProfile);
  2. DisplayWidget.h line 95 class DisplayWidget : public QOpenGLWidget, protected OpenGLFunctions
  3. Change the include path in "preferences" to the example include path Examples/Include
3Dickulus commented 5 years ago

oops, will close after your response :)

3Dickulus commented 5 years ago

the bundle at https://github.com/3Dickulus/FragM/releases was compiled with the above changes. can you, shengsword, verify that it is working? or anyone else ???

shengsword commented 5 years ago

I have already checked the releases on different macs before, all have shader version error...

3Dickulus commented 5 years ago

Ok, (and thank you very much for your time) this confirms..??

I'm wondering if it needs a real mac to build on and the travis-ci emulation is not quite right...

so not sure what to do other than compile on a real mac instead of travis-ci emulation/image I guess it might be that there is no gfx card or that it's simulation is close but not perfect?

in either case I won't be able to provide a working app bundle via travis-ci... edit:unless it can be made to work. any suggestions?

3Dickulus commented 5 years ago

Closing this because it does compile and run on osx.