Skip to content

Add macOS ARM64 support - #445

Open
AnthonyKwon wants to merge 3 commits into
videolan:3.xfrom
AnthonyKwon:3.x
Open

Add macOS ARM64 support#445
AnthonyKwon wants to merge 3 commits into
videolan:3.xfrom
AnthonyKwon:3.x

Conversation

@AnthonyKwon

Copy link
Copy Markdown

Description of Change

Added Apple Silicon Mac support as Windows-style path structure.
It still works with current VideoLAN.LibVLC.Mac package on x86, but it needs patched package with path structure changed and ARM64 files added to work on Apple Silicon.
PoC implementation of libvlc-nuget is available on AnthonyKwon/libvlc-nuget. (It's not ready to be upstreamed yet as it uses hacky method to package)

Issues Resolved

API Changes

  • internal const string ArchitectureNames.MacOSArm64 in Constants.cs

Platforms Affected

  • macOS

Behavioral/Visual Changes

None

Before/After Screenshots

Not applicable

Testing Procedure

  • build this fork as standard LibVLCSharp macOS build procedure with all dependencies
  • or, trim every other mobile and tvOS targets and its dependencies except net9.0-macos and net10.0-macos from TargetFramework and build only with Xcode needed.
    Since you're going to test only with macOS target, other targets are not needed to be tested.
    I used this method for testing since I was unable to successfully build on some mobile platform. (seems not relevant with these changes since I was not even able to build pure LibVLCSharp)
build.webm

PR Checklist

  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

@mfkl

mfkl commented Aug 4, 2026

Copy link
Copy Markdown
Member

Thanks, code looks clean. This could be a single commit, you can fold them.

I'd like to see the build procedure for libvlc arm64 mac though.

And it'd be nice to make sure we still support mono and netcore targets, this was an issue when testing #163

@AnthonyKwon

AnthonyKwon commented Aug 4, 2026

Copy link
Copy Markdown
Author

I tried mono and netcore sample and it was failed for another reason. mono just simply throw no such file or directory so I need to see what's going on more, but I'm sure netcore doesn't support Apple Silicon since it throw bad CPU type.
I think it's because they're using old .NET version, so they lacks ARM64 support.
I'll upload video of building my fork of libvlc-nuget soon.

@AnthonyKwon

Copy link
Copy Markdown
Author

It downloads Intel and Apple Silicon variant of VLC, extracts it with 7z, and repackages it as correct structure.
yeah. really hacky method since I only considered personal usage when I first forked it. it needs much more care 😅

nuget-build.webm

@mfkl

mfkl commented Aug 4, 2026

Copy link
Copy Markdown
Member

that build is GPL also, so you're breaking the license unless your app is opensource. Hence why a proper libvlckit build is needed :)

@AnthonyKwon

Copy link
Copy Markdown
Author

yeah, my personal project is licensed with GPL so it's fine with it, but it needs to be split as LGPL/GPL variant like Windows if it's gonna actually used. but I think there might be alternative method.

@mfkl

mfkl commented Aug 4, 2026

Copy link
Copy Markdown
Member

the current vlckit nuget build is static (1 binary), the one from VLC is not (hundreds of plugins). This will break existing users. So lets make a static build of latest vlckit, for both x64 and arm, for 3.x branch, here on github.

@mfkl

mfkl commented Aug 4, 2026

Copy link
Copy Markdown
Member

or accept the breakage and publish both builds (x64 and arm) as dynamic

@AnthonyKwon

Copy link
Copy Markdown
Author

I made it work with statically built libvlc with new path scheme. but since this change might introduce real breakage which has possibility to break other OS, it needs more discussion before gets pushed here. (touches library loading)
I'll commit it later since current code is just hard-coded mess to just run demo for verifying my theory.

image

@AnthonyKwon

Copy link
Copy Markdown
Author

I have no idea about vlckit since it's new for me. I even never tried to build until you said it :(
at least (improved version of) workaround above seems make it load. I'll see what can I do for it.

@AnthonyKwon

AnthonyKwon commented Aug 5, 2026

Copy link
Copy Markdown
Author

seems like vlckit already can produce universal binary. it only needs sdk version set to higher one.
I'll leave detail separately on vlckit side. if universal binary is gonna be used, this PR no longer needed since that binary already runs with current code :)


#if NET5_0_OR_GREATER
// register custom resolver to load library from discovered path
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), (dll, _, _) =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why make this call right after LoadNativeLibrary succeeded? This looks off.

@AnthonyKwon AnthonyKwon Aug 5, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

to filter out working path. I know it feels off, but when I looked for the P/Invoke exception causes (with inserting debug lines), it was coming from DllImport of LibVLCVersion(), and macOS seems to be have no problem at DlOpen() the LibVLC without path change, but calling any method throws error.
maybe I can add && MAC to condition if you're unsure about it :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

and this is why I'm calling it "workaround". maybe someone else who has better knowledge at low-level can bring better way to do it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok. but first as I said. libvlc build is the initial step.

@AnthonyKwon

Copy link
Copy Markdown
Author

I opened libvlc-nuget PR with static build on mfkl/libvlc-nuget#59.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants