Skip to content

Conversation

uiryuu
Copy link
Member

@uiryuu uiryuu commented Jun 8, 2024


Description:
This PR bumps mpv and FFmpeg to the latest release version. The corresponding header files are also updated.

  • mpv to 0.38.0 (on the release/1.4.0 branch in IINA's fork of mpv, which contains fixes for the 0.38.0 release from the master branch)
  • FFmpeg to 7.0.1

Use these libs to test out: lib.zip. Unzip lib.zip and replace with deps/lib. Note that the libraries are only for arm and macOS 12+.

The new libs have not uploaded to the server, so don't try to download them using other/download_libs.sh as it will still download the old libs.

mpv still cannot compile when targeting macOS 10.15 (for x86), track here

The libwebp in the webp package contains @rpath references when --build-from-soruce. This will cause libsharpyuv.dylib failed to be copied to the libs folder. The change_lib_dependencies.rb is modified to handle this case.

The swift package also got upgraded:

  • PromiseKit from 6.13.3 to 6.22.1 (the latest release is version 8; stayed on the latest release of version 6)
  • GRMustache from 4.0.1 to 4.2.0 (latest)
  • Sparkle from 2.4.0 to 2.6.3 (latest, w/ Sonoma improvements)

The Gzip swift package is removed since we're not using it anymore (correct me if I'm wrong).


Updates on compilation on 10.15 (x86 only)

libjxl will not compile w/ the latest Xcode toolchain available on 10.15 (Xcode 12.4). According to libjxl/libjxl#2461 (comment), I had to install gcc from homebrew (gcc 14) and force libjxl to use gcc-14 instead of Xcode toolchain.

@uiryuu uiryuu requested a review from low-batt June 8, 2024 07:41
Copy link
Contributor

@low-batt low-batt left a comment

Choose a reason for hiding this comment

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

Multiple problems…

  1. Taking a JPEG XL screen shot failed with:
    17:05:51.248 [ffmpeg][e] Unexpected encoding: libjxl (258)

Was FFmpeg built with --enable-libjxl?

This was a build error on my part. JPEG XL is working.

  1. Need to run other/parse_doc.rb so that the generated mpv interface classes, MPVCommand, MPVOption.swift and MPVProperty.swift match the version of mpv.

This has been done, HOWEVER the generator needs to be updated and MPVProperty.swift regenerated as indicated in my comments below. Those comments also provide more details on the code that needs to be updated due to mpv changes.

As a part of that these changes will be needed:

  • MPVOption.Screenshot.screenshotDirectory must be changed to MPVOption.Screenshot.screenshotDir in MPVController and PlayerCore
  • MPVProperty.videoAspect must be changed to MPVOption.Video.videoAspectOverride in PlayerCore

There are a couple of other missing properties such as video-codec and video-format. I've not tracked down what has happened to them yet.

  1. I am unable to build iina-plugin. I get this failure:
/Users/low-batt/Documents/builds/iina-official/iina/iina-plugin/main.swift:10:8: error: missing required module 'GRMustacheKeyAccess'
import Mustache

I tried reseting the package caches. Deleting Xcode caches. Didn't work. To be able to test I had to delete the iina-plugin project. Some sort of Xcode bug? I'm using Xcode 15.2.

This has been fixed by commit db9f0fb.

  1. Spinning wheel of death when playing with HDR enabled on a Mac that supports EDR.

Very hard to investigate this because the Mac locks up so much that nothing responds. With much trouble I was able to capture a process sample. This: _NSCGSDisplayConfigurationMaximumHDRValueChangedNotificationHandler is macOS sending updates as the capabilities of the display changes. I have found that these updates are emitted at a high rate, especially when you first activate EDR. This is expected. But during the processing a method _CSCheckFix is calling _os_log_debug_impl. All the time is spent logging.

Once I saw this I clicked on Show Build Folder in Finder and executed IINA directly instead of from Xcode. The performance issue was gone. So this has something to do with the Xcode console now being tied into oslog. That is new to Xcode 15. Maybe I've not tried HDR since upgrading Xcode and this has nothing to do with the mpv upgrade? I will look into that.

This is not a problem with this PR. It is not reproducible on my Mac running macOS Sonoma and Xcode 15.4. I encountered this under macOS Ventura and Xcode 15.2. Seems like Apple has fixed this one.

Process sample::
    +       !       :     |     +       ! : 4775 _NSCGSDisplayConfigurationMaximumHDRValueChangedNotificationHandler  (in AppKit) + 264  [0x1abbfaf80]
    +       !       :     |     +       ! : | 4759 _NSCGSDisplayConfigurationUpdateAndInvokeObservers  (in AppKit) + 68  [0x1abbfa6b8]
    +       !       :     |     +       ! : | + 4740 _NSCGSDisplayConfigurationUpdate  (in AppKit) + 912  [0x1abbfb79c]
    +       !       :     |     +       ! : | + ! 4740 _NSCGSCreateArrayUsingBlock  (in AppKit) + 196  [0x1ab5a8cdc]
    +       !       :     |     +       ! : | + !   4740 ___NSCGSCreateDisplaysFromDisplayIDsUsingPredicate_block_invoke  (in AppKit) + 76  [0x1ab5a8e44]
    +       !       :     |     +       ! : | + !     4739 -[NSCGSDisplay initWithDisplayID:flipOffset:]  (in AppKit) + 816  [0x1ab5a9260]
    +       !       :     |     +       ! : | + !     : 4736 SLDisplayCopyAllDisplayModes  (in SkyLight) + 348  [0x1ad27a7b8]
    +       !       :     |     +       ! : | + !     : | 2382 display_mode_is_legacy_listed  (in SkyLight) + 116  [0x1acfc3fcc]
    +       !       :     |     +       ! : | + !     : | + 2382 _CSCheckFix  (in CarbonCore) + 636  [0x1ab0dad44]
    +       !       :     |     +       ! : | + !     : | +   2381 _os_log_debug_impl  (in libsystem_trace.dylib) + 24  [0x1a805185c]
    +       !       :     |     +       ! : | + !     : | +   ! 2379 _os_log  (in libsystem_trace.dylib) + 152  [0x1a804f064]

@uiryuu
Copy link
Member Author

uiryuu commented Jun 9, 2024

Need to run other/parse_doc.rb so that the generated mpv interface classes, MPVCommand, MPVOption.swift and MPVProperty.swift match the version of mpv.

Fixed in the pushed commit. Actually I did this, but git status didn't give me any changes, so I just moved on. What I didn't know is that the generated files are in the same folder asprase_doc.rb and those newly generated swift files are ignored by git... I'll change this behavior later, at least print something to tell the user to copy the files to the designated folder.

Based on the changes of mpv options and properties, I think we need to do some changes in our code to reflect some of their name changes, right?

Was FFmpeg built with --enable-libjxl?

Yes it was. Weird, I'll do some investigation.

@low-batt
Copy link
Contributor

low-batt commented Jun 9, 2024

Yes, we need to make some changes in IINA as mpv renamed some of the properties/options we are using. IINA won't build with the updated generated files. I listed a couple of the changes needed above. These changes were in the list of changes mpv publishes. But video-format and video-codec and audio-codec have disappeared. They are used for the Inspector window. I've not been able to find out what happened to them.

And yes, the behavior of the generator script is confusing. I guess there was a concern about possibly stepping on some local changes? Otherwise it probably should put the files in their proper place.

The FFmpeg build missing --enable-libjxl was my best guess on what the FFmpeg error was about. I will have to look closer into that one if we have built FFmpeg with libjxl support.

@low-batt
Copy link
Contributor

low-batt commented Jun 9, 2024

Another thing I forgot. We have a lot of dangling references in the Xcode project to header files that have been removed. We should clean those up as well.

@low-batt
Copy link
Contributor

low-batt commented Jun 9, 2024

This is the mpv commit that removed properties like video-codec: mpv-player/mpv@e720159

@low-batt
Copy link
Contributor

low-batt commented Jun 9, 2024

This mpv commit removed the restriction on using current-tracks: mpv-player/mpv@e16d0dd

@low-batt
Copy link
Contributor

low-batt commented Jun 9, 2024

To fix the compilation errors in the Inspector code we first need to remove this code in parse_doc.rb:

  if name.include? 'current-tracks'
    # According to the mpv documentation this property is not supposed to be
    # used programmatically. We still output a comment for the property so
    # people can figure out why the Swift constant is missing.
    file.write "  /** #{name}  As per mpv docs, scripts etc. should not use this. */\n"

That restriction has been removed. We need to use that property because these properties that we were using have been removed from the documentation as mpv would prefer clients use the actual properties instead of these aliases:

M_PROPERTY_ALIAS("audio-codec", "current-tracks/audio/codec-desc"),
M_PROPERTY_ALIAS("video-format", "current-tracks/video/codec"),
M_PROPERTY_ALIAS("video-codec", "current-tracks/video/codec-desc"),

puts "=== Fix dependencies for #{file} ==="
dylib = DylibFile.new file
dylib.change_id!
dylib.deps.each do |dep|
if dep.start_with?(prefix)
if dep.start_with?(prefix) || dep.start_with?("@rpath")
Copy link
Member

Choose a reason for hiding this comment

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

use or

fix_count += 1
basename = File.basename(dep)
new_name = "@rpath/#{basename}"
dylib.change_install_name!(dep, new_name)
dest = File.join(lib_folder, basename)
src =
if dep.start_with?(prefix)
Copy link
Member

Choose a reason for hiding this comment

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

Keep them in the same line src = if ...

@lhc70000
Copy link
Member

Updated parse_doc.rb and fixed build errors.

@low-batt
Copy link
Contributor

Reviewed latest changes. Built and runs without errors for me.

There are lots of dangling references under deps/include in the Xcode project. Since we are updating the includes we might as well fix that as well in this PR.

Do you want me to take care of that?

@uiryuu
Copy link
Member Author

uiryuu commented Jun 18, 2024

There are lots of dangling references under deps/include in the Xcode project.

Are you talking about we have unused headers from mpv and FFmpeg? Even if we have some headers that are not explicitly used in our code, specifically iina-Bridging-Header.h, they are cross-referenced. If we only keep the headers we used, the compiler will not find other headers which are referenced. I, too, have considered to keep minimum header files, but in order to do that we have to resolve the dependency tree and see which headers are not referenced in anywhere. And we need to do that every time after we update the headers, so I just poured every header files from mpv and FFmpeg and called it a day. Is this what you want to do?

@low-batt
Copy link
Contributor

Not that. It is that the Xcode project has references to headers that do not exist. Open up the group for libavutil in Xcode and you will see Xcode shows many in red, as in it can't find the file. At least that is what I'm seeing.

@uiryuu
Copy link
Member Author

uiryuu commented Jun 18, 2024

Sorry but I'm not seeing it on this bump-mpv branch. Can you provide a screenshot of missing headers?
image

@low-batt
Copy link
Contributor

dangling

Most of those files are missing for me:

low-batt@gag libavutil (bump-mpv $%=)$ ls -la
total 680
drwxr-xr-x  25 low-batt  staff    800 Jun 17 21:01 .
drwxr-xr-x   8 low-batt  staff    256 Apr 20  2023 ..
-rw-r--r--   1 low-batt  staff    336 Aug 18  2023 .gitignore
-rw-r--r--   1 low-batt  staff   4850 Aug 18  2023 attributes.h
-rw-r--r--@  1 low-batt  staff    180 Sep 22  2022 avconfig.h
-rw-r--r--   1 low-batt  staff   9495 Jun 17 21:01 avutil.h
-rw-r--r--   1 low-batt  staff  11998 Aug 18  2023 buffer.h
-rw-r--r--   1 low-batt  staff  32445 Jun 17 21:01 channel_layout.h
-rw-r--r--   1 low-batt  staff  17130 Jun 17 21:01 common.h
-rw-r--r--   1 low-batt  staff   9374 Aug 18  2023 dict.h
-rw-r--r--   1 low-batt  staff   5489 Aug 18  2023 error.h
-rw-r--r--   1 low-batt  staff  38049 Jun 17 21:01 frame.h
-rw-r--r--   1 low-batt  staff  24079 Jun 17 21:01 hwcontext.h
-rw-r--r--   1 low-batt  staff  14172 Aug 18  2023 imgutils.h
-rw-r--r--@  1 low-batt  staff   1726 Sep 22  2022 intfloat.h
-rw-r--r--   1 low-batt  staff  12766 Aug 18  2023 log.h
-rw-r--r--   1 low-batt  staff   2304 Aug 18  2023 macros.h
-rw-r--r--   1 low-batt  staff   3944 Apr 25  2023 mastering_display_metadata.h
-rw-r--r--   1 low-batt  staff   9563 Jun 17 21:01 mathematics.h
-rw-r--r--   1 low-batt  staff  20457 Jun 17 21:01 mem.h
-rw-r--r--   1 low-batt  staff  16165 Jun 17 21:01 pixdesc.h
-rw-r--r--   1 low-batt  staff  41797 Jun 17 21:01 pixfmt.h
-rw-r--r--   1 low-batt  staff   6286 Jun 17 21:01 rational.h
-rw-r--r--   1 low-batt  staff  10301 Jun 17 21:01 samplefmt.h
-rw-r--r--   1 low-batt  staff   4335 Jun 17 21:01 version.h
low-batt@gag libavutil (bump-mpv $%=)$

@low-batt
Copy link
Contributor

The .gitignore excludes most of those files from git:

low-batt@gag libavutil (bump-mpv $%=)$ cat .gitignore 
# Exclude everything except the FFmpeg headers IINA needs.
*
!.gitignore
!attributes.h
!avconfig.h
!avutil.h
!buffer.h
!channel_layout.h
!common.h
!dict.h
!error.h
!frame.h
!hwcontext.h
!imgutils.h
!intfloat.h
!log.h
!macros.h
!mastering_display_metadata.h
!mathematics.h
!mem.h
!pixdesc.h
!pixfmt.h
!rational.h
!samplefmt.h
!version.h
low-batt@gag libavutil (bump-mpv $%=)$ 

@uiryuu
Copy link
Member Author

uiryuu commented Jun 18, 2024

@low-batt Sorry I didn't check the gitginore. I saw this file was maintain by you, so please deal with this issue.

@uiryuu uiryuu marked this pull request as ready for review June 20, 2024 03:16
uiryuu and others added 9 commits June 20, 2024 19:36
The `libwebp` in the `webp` package contains `@rpath` references when
`--build-from-soruce`. This will cause `libsharpyuv.dylib` failed to be
copied to the libs folder. Update the script to handle this case.
- Removed Gzip since we are not using it anymore
- Upgraded:
  - PromiseKit from 6.13.3 to 6.22.1 (the latest release is version 8)
  - GRMustache from 4.0.1 to 4.2.0 (latest)
  - Sparkle from 2.4.0 to 2.6.3 (latest, w/ Sonoma improvements)
This commit will add two additional libraries that are only needed on
Macs with Intel chips.
@lhc70000
Copy link
Member

Updated libs on server & rebased. Merging.

@lhc70000 lhc70000 merged commit a4fdaff into develop Jun 20, 2024
@lhc70000 lhc70000 deleted the bump-mpv branch June 20, 2024 23:36
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.

3 participants