mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
26.69k stars 2.83k forks source link

mpv 0.38.0 Cannot be Built on macOS 10.15 #14310

Closed uiryuu closed 2 weeks ago

uiryuu commented 3 weeks ago

Important Information

Reproduction Steps

The IINA project is planning to use the latest version of mpv for the next release. As mpv claims to support macOS 10.15 or later in the current readme, we decide to build libmpv on a 10.15 mac as the dependency of IINA, and bump the system requirement for IINA to 10.15. We tried to build mpv without any custom flags to reproduce the issue:

Expected Behavior

mpv should build normally.

Actual Behavior

mpv failed to compile due to usage of newer macOS APIs. For instance: https://github.com/mpv-player/mpv/blob/112fa549beb52ab3d75999c8d8a82936e13001c4/osdep/mac/log_helper.swift#L23 Logger is only available for macOS 11+.

See the attached build_error.log for more details.

Log File

build_error.log meson_setup_build.log meson-log.txt

I carefully read all instruction and confirm that I did the following:

Akemi commented 3 weeks ago

... As mpv claims to support macOS 10.15 or later in the current readme, we decide to build libmpv on a 10.15 mac as the dependency of IINA, and bump the system requirement for IINA to 10.15. ...

on a side note, this is runtime support and not build support. some of the build errors you have are because of too old dev tools, like swift, SDK, etc.

using the logger though, is a legitimate problem.

Akemi commented 3 weeks ago

i opened a PR #14334 to fix 2 of the issues. though there are still some others.

syntax problem. not sure yet swift 5.6 language feature that will be mandatory in 6.0 (https://www.donnywals.com/what-is-the-any-keyword-in-swift/). will fix that one for now. when swift 6.0 comes out we will see how to handle this one.

../osdep/mac/event_helper.swift:78:38: error: expected ',' separator
    func subscribe(_ subscriber: any EventSubscriber, event: Event) {
                                     ^
                                    ,
../osdep/mac/event_helper.swift:78:38: error: unnamed parameters must be written with the empty name '_'
    func subscribe(_ subscriber: any EventSubscriber, event: Event) {
                                     ^
                                     _: 
../osdep/mac/event_helper.swift:78:34: error: cannot find type 'any' in scope
    func subscribe(_ subscriber: any EventSubscriber, event: Event) {

can't infer type even though the type should be inferable from the function. probably from the problem above. should be fixed with above fix

../video/out/cocoa_cb_common.swift:39:54: error: cannot infer contextual base in reference to member 'init'
        AppHub.shared.event?.subscribe(self, event: .init(name: "MPV_EVENT_SHUTDOWN"))
                                                    ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:98:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "duration", format: MPV_FORMAT_DOUBLE))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:99:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "time-pos", format: MPV_FORMAT_DOUBLE))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:100:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "speed", format: MPV_FORMAT_DOUBLE))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:101:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "pause", format: MPV_FORMAT_FLAG))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:102:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "media-title", format: MPV_FORMAT_STRING))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:103:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "chapter-metadata/title", format: MPV_FORMAT_STRING))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:104:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "metadata/by-key/album", format: MPV_FORMAT_STRING))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/remote_command_center.swift:105:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "metadata/by-key/artist", format: MPV_FORMAT_STRING))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/touch_bar.swift:144:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "duration", format: MPV_FORMAT_DOUBLE))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/touch_bar.swift:145:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "time-pos", format: MPV_FORMAT_DOUBLE))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/touch_bar.swift:146:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "speed", format: MPV_FORMAT_DOUBLE))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/touch_bar.swift:147:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "pause", format: MPV_FORMAT_FLAG))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../osdep/mac/touch_bar.swift:148:40: error: cannot infer contextual base in reference to member 'init'
        event?.subscribe(self, event: .init(name: "MPV_EVENT_END_FILE"))
                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

with macOS 10.15 compat i meant the latest version. since it uses SDK 11.0 this shouldn't be a problem. though in the worst case we need to add a platform check for this too. put it behind a guard

../video/out/cocoa_cb_common.swift:138:76: error: 'displayP3_PQ' is only available in macOS 10.15.4 or newer
        case MAC_CSP_DISPLAY_P3_PQ: return CGColorSpace(name: CGColorSpace.displayP3_PQ)

i wonder what apple fucked up with the definition of those two here. both are available on 11.0, and both are guarded behind a platform check properly. https://developer.apple.com/documentation/coregraphics/cgcolorspace/3571187-itur_2100_hlg https://developer.apple.com/documentation/coregraphics/cgcolorspace/3571188-itur_2100_pq i added a compatibility fix for apparently broken SDK11.

../video/out/cocoa_cb_common.swift:152:78: error: extra argument 'name' in call
            case MAC_CSP_BT_2100_HLG: return CGColorSpace(name: CGColorSpace.itur_2100_HLG)
                                                                ~~~~~~~~~~~~~^~~~~~~~~~~~~
../video/out/cocoa_cb_common.swift:152:58: error: missing arguments for parameters 'calibratedGrayWhitePoint', 'blackPoint', 'gamma' in call
            case MAC_CSP_BT_2100_HLG: return CGColorSpace(name: CGColorSpace.itur_2100_HLG)
                                                         ^
../video/out/cocoa_cb_common.swift:152:78: error: type 'CGColorSpace' has no member 'itur_2100_HLG'
            case MAC_CSP_BT_2100_HLG: return CGColorSpace(name: CGColorSpace.itur_2100_HLG)
                                                                ~~~~~~~~~~~~ ^~~~~~~~~~~~~

../video/out/cocoa_cb_common.swift:153:77: error: extra argument 'name' in call
            case MAC_CSP_BT_2100_PQ: return CGColorSpace(name: CGColorSpace.itur_2100_PQ)
                                                               ~~~~~~~~~~~~~^~~~~~~~~~~~
../video/out/cocoa_cb_common.swift:153:57: error: missing arguments for parameters 'calibratedGrayWhitePoint', 'blackPoint', 'gamma' in call
            case MAC_CSP_BT_2100_PQ: return CGColorSpace(name: CGColorSpace.itur_2100_PQ)
                                                        ^
../video/out/cocoa_cb_common.swift:153:77: error: type 'CGColorSpace' has no member 'itur_2100_PQ'
            case MAC_CSP_BT_2100_PQ: return CGColorSpace(name: CGColorSpace.itur_2100_PQ)
                                                               ~~~~~~~~~~~~ ^~~~~~~~~~~~

wonder why this needs to be unwrapped since init expects an optional. something fixed in newer swift versions?

../osdep/mac/touch_bar.swift:95:25: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                image: .init(named: NSImage.touchBarPauseTemplateName),
                        ^
../osdep/mac/touch_bar.swift:95:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                image: .init(named: NSImage.touchBarPauseTemplateName),
                        ^
                                                                       ?? <#default value#>
../osdep/mac/touch_bar.swift:95:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                image: .init(named: NSImage.touchBarPauseTemplateName),
                        ^
                                                                      !
../osdep/mac/touch_bar.swift:96:28: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                imageAlt: .init(named: NSImage.touchBarPlayTemplateName),
                           ^
../osdep/mac/touch_bar.swift:96:28: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                imageAlt: .init(named: NSImage.touchBarPlayTemplateName),
                           ^
                                                                         ?? <#default value#>
../osdep/mac/touch_bar.swift:96:28: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                imageAlt: .init(named: NSImage.touchBarPlayTemplateName),
                           ^
                                                                        !
../osdep/mac/touch_bar.swift:102:25: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                image: .init(named: NSImage.touchBarGoBackTemplateName),
                        ^
../osdep/mac/touch_bar.swift:102:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                image: .init(named: NSImage.touchBarGoBackTemplateName),
                        ^
                                                                        ?? <#default value#>
../osdep/mac/touch_bar.swift:102:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                image: .init(named: NSImage.touchBarGoBackTemplateName),
                        ^
                                                                       !
../osdep/mac/touch_bar.swift:108:25: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                image: .init(named: NSImage.touchBarGoForwardTemplateName),
                        ^
../osdep/mac/touch_bar.swift:108:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                image: .init(named: NSImage.touchBarGoForwardTemplateName),
                        ^
                                                                           ?? <#default value#>
../osdep/mac/touch_bar.swift:108:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                image: .init(named: NSImage.touchBarGoForwardTemplateName),
                        ^
                                                                          !
../osdep/mac/touch_bar.swift:114:25: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                image: .init(named: NSImage.touchBarSkipBackTemplateName),
                        ^
../osdep/mac/touch_bar.swift:114:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                image: .init(named: NSImage.touchBarSkipBackTemplateName),
                        ^
                                                                          ?? <#default value#>
../osdep/mac/touch_bar.swift:114:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                image: .init(named: NSImage.touchBarSkipBackTemplateName),
                        ^
                                                                         !
../osdep/mac/touch_bar.swift:120:25: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                image: .init(named: NSImage.touchBarSkipAheadTemplateName),
                        ^
../osdep/mac/touch_bar.swift:120:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                image: .init(named: NSImage.touchBarSkipAheadTemplateName),
                        ^
                                                                           ?? <#default value#>
../osdep/mac/touch_bar.swift:120:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                image: .init(named: NSImage.touchBarSkipAheadTemplateName),
                        ^
                                                                          !
../osdep/mac/touch_bar.swift:126:25: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                image: .init(named: NSImage.touchBarAudioInputTemplateName),
                        ^
../osdep/mac/touch_bar.swift:126:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                image: .init(named: NSImage.touchBarAudioInputTemplateName),
                        ^
                                                                            ?? <#default value#>
../osdep/mac/touch_bar.swift:126:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                image: .init(named: NSImage.touchBarAudioInputTemplateName),
                        ^
                                                                           !
../osdep/mac/touch_bar.swift:132:25: error: value of optional type 'NSImage?' must be unwrapped to a value of type 'NSImage'
                image: .init(named: NSImage.touchBarComposeTemplateName),
                        ^
../osdep/mac/touch_bar.swift:132:25: note: coalesce using '??' to provide a default when the optional value contains 'nil'
                image: .init(named: NSImage.touchBarComposeTemplateName),
                        ^
                                                                         ?? <#default value#>
../osdep/mac/touch_bar.swift:132:25: note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
                image: .init(named: NSImage.touchBarComposeTemplateName),
                        ^
                                                                        !
Akemi commented 2 weeks ago

i think i fixed all the issues now, besides the one you mentioned on the PR with avfoundation ao and the last one mentioned in my previous comment with the unwrapping of the NSImage. for the former it's just a case of what to do, for the latter i am not sure why it is even complaining and it seems like a swift bug still?

Akemi commented 2 weeks ago

would you mind trying to build from the mentioned PR and let me know if the problems have been solved, which still persist and if anything new popped up? if there are still problems the log files would be appreciated again.

uiryuu commented 2 weeks ago

Thanks for your work. I tried to build against the PR on my macOS 10.15 machine. The NSImage init problem in touchbar support still exists which prevent mpv from compiling. It looks like a swift bug, and if that doesn't exist when using newer toolchain, we can ignore it.

Then I tried to build using

meson setup build -Dmacos-touchbar=disabled
meson compile -C build

and it compiled.

Akemi commented 2 weeks ago

thanks for testing, will merge the fixes soon. if your use-case is libmpv only for iina, i would also suggest disabling cocoa-cb.