nununoisy / gb-presenter-rs

GBS/LSDj visualizer based on SameBoy and FFmpeg
MIT License
58 stars 1 forks source link

fails to compile in MacOS (Apple Silicon) #8

Closed jamesellinger closed 3 months ago

jamesellinger commented 4 months ago

Note: gb-presenter-rs works just fine on MacOS via wine (in my case wine-staging 9.8).

But out of curiosity I tried to compile from source. I'm running an Apple Silicon M1 pro on Sonoma 14.4.1.

As far I can tell I have all of the following taken care of:

But when I run cargo build --release it fails.

I have attached the output from terminal if that helps.

Terminal Saved Output.txt

nununoisy commented 3 months ago

Looks like the issue is that I haven't updated ffmpeg-next in a while, and you've installed FFmpeg 7. Try bumping ffmpeg-next and ffmpeg-sys-next in Cargo.toml to 7.0.2 and see if it builds.

jamesellinger commented 3 months ago

Thanks for getting back about this.

Made the changes in Cargo.toml, which resolves the problems with ffmpeg-next and ffmpeg-sys-next.

There still seems to be a problem with sameboy-sys. I think I have the SameBoy build environment correct:

sameboy-sys output.txt

but cargo build --release fails with errors and warnings related to sameboy-sys:

cargo build output.txt

I wasn't sure if it had to do with build architecture, so I used arch -x86_64 zsh to change to x86, but the result is the same.

nununoisy commented 3 months ago

I'm assuming you're using Apple Clang (from the XCode Command Line Tools) - sometimes it doesn't support certain types of autovectorization. This isn't usually an issue but I've put in a -Werror flag in the build script, since it's also present in SameBoy's makefile.

The autovectorization is disabled on debug builds, which explains why it seems to build properly.

Would you please try removing this line in sameboy-sys/build.rs, and sending the build output once again so I can see what warnings are emitted on arm64 macOS? https://github.com/nununoisy/gb-presenter-rs/blob/2866c7a0bef080d8b27bcc1a6c9998d313910ccf/sameboy-sys/build.rs#L120

jamesellinger commented 3 months ago

Thanks again for looking into this. I removed the line as your suggested. The new output it below.

cargo build output 0601.txt

I realized one thing I forgot to mention in my last post, I updated Cargo.toml as you suggested so that ffmpeg-next and ffmpeg-sys-next were both set to 7.0.2. I got the following error:

error: failed to select a version for the requirement ffmpeg-sys-next = "^7.0.2" candidate versions found which didn't match: 7.0.0, 6.1.0, 6.0.1, ...

so I set ffmpeg-sys-next = "7.0.0"

So I'm not sure if that is related to the problem.

nununoisy commented 3 months ago

Looks like a feature was removed in FFmpeg 7.0. Try commenting out the line it's complaining about and see if it builds. It should still set the audio layout to stereo thanks to the call to set_channel_layout. If this builds, I can look into feature-gating or removing that line.

https://github.com/nununoisy/gb-presenter-rs/blob/2866c7a0bef080d8b27bcc1a6c9998d313910ccf/src/video_builder/mod.rs#L217

jamesellinger commented 3 months ago

It builds now!

I can render video from the command line with arguments, but when opening a GUI it crashes when I click Browse... to choose a file. Other buttons that bring up a file dialog don't crash (see attached image).

gb-presenter-rs screen

I ran with a backtrace and get the following output:

rust backtrace.txt

And just in case it's useful here is the entire output from Apple's crash log:

gb-presenter-rs apple crash output.txt

jamesellinger commented 3 months ago

p.s.

I built spc-presenter and nsf-presenter after applying the suggestions in Cargo.toml for ffmpeg-next and commenting out set_channels.

They don't crash when clicking Browse...

nununoisy commented 3 months ago

Hmm... there's only one thing that differentiates the dialogs, and that's the construction of the dialog. In GBPresenter, the ROM input dialog needs different filters for running 2x LSDj songs. I unfortunately don't have an arm64 macOS device to test on, but I do have an idea as to how to make it work. Try replacing this function body:

https://github.com/nununoisy/gb-presenter-rs/blob/2866c7a0bef080d8b27bcc1a6c9998d313910ccf/src/gui/mod.rs#L54-L70

with this:

fn browse_for_rom_dialog(for_2x: bool) -> Option<String> {
    let file = if !for_2x {
        FileDialog::new()
            .add_filter("All supported formats", &["gb", "gbs", "vgm", "vgz", "vgm.gz"])
            .add_filter("LSDj ROMs", &["gb"])
            .add_filter("GameBoy Sound Files", &["gbs"])
            .add_filter("VGM Log Files", &["vgm", "vgz", "vgm.gz"])
            .show_open_single_file()
    } else {
        FileDialog::new()
            .add_filter("LSDj ROMs", &["gb"])
            .show_open_single_file()
    };

    match file {
        Ok(Some(path)) => Some(path.to_str().unwrap().to_string()),
        _ => None
    }
}
jamesellinger commented 3 months ago

I replaced the function body with the new code. That didn't fix the crashing. On a whim I removed , "vgm.gz" from the filters and now the file dialog opens without crashing.

I've only been working with gbs files, so I don't know how that change would affect other file types. Now I can open a song and render from the GUI.

Thanks for dishing out so many suggestions. Like I said in the first post, gb-presenter, as well as spc-presenter and nsf-presenter, run just fine via wine.

nununoisy commented 3 months ago

Thanks for working this out. I've opened an issue in the library I'm using to display the file dialog. In the meantime, I'll exclude the vgm.gz filter on macOS targets.