libvlcsharp icon indicating copy to clipboard operation
libvlcsharp copied to clipboard

Winui 3.x

Open mfkl opened this issue 1 year ago • 11 comments

Description of Change

Add WinUI support to LVS 3

Issues Resolved

  • fixes https://code.videolan.org/videolan/LibVLCSharp/-/issues/347

Platforms Affected

  • UWP

PR Checklist

  • [x] Rebased on top of the target branch at time of PR

  • [x] Changes adhere to coding standard

  • [ ] Need to add some docs

  • [ ] Clean up commits.

  • [ ] 3.0.18 libvlc.windows on nuget.

  • [ ] test unpackaged mode

WinUI 3 only is supported. Minimal target is net6.0-windows10.0.17763.0. WinUI support requires a libvlc 3.0.18 build that needs to be pushed to NuGet before that PR.

UWP namespace for WinUI is suboptimal but there is no proper way to have it be .WinUI due to the different Generic.xaml.

Packaged mode has been tested. Unpackaged seems to have some loading issue (but likely my setup isn't right).

mfkl avatar Aug 09 '22 09:08 mfkl

  C:\hostedtoolcache\windows\dotnet\sdk\6.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(293,5): error NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Please verify you are using a supported runtime identifier, or set the PublishReadyToRun property to false. [D:\a\1\s\samples\LibVLCSharp.WinUI.Sample\LibVLCSharp.WinUI.Sample.csproj]

CI ain't happy. Can't repro locally.

mfkl avatar Aug 09 '22 15:08 mfkl

This is blocked by the need for a newer LibVLC.Windows version since the WinUI 3.x implementation relies on a new native change not present in the current 3.0.17.4 build.

The official VLC 3.0.18 release is under way, RC and tagging is happening in the coming weeks. Stay tuned.

mfkl avatar Aug 22 '22 05:08 mfkl

UWP namespace for WinUI is suboptimal but there is no proper way to have it be .WinUI due to the different Generic.xaml

The UWP namespace is really weird. Why you don't want to use a different namespace in Generic.xaml for the WinUI platform ?

In my memories, we could do something like that : In AssemblyInfo.cs

#if WinUI
[assembly: XmlnsDefinition("libvlcsharp", "LibVLCSharp.Platforms.WinUI")]
#else
[assembly: XmlnsDefinition("libvlcsharp", "LibVLCSharp.Platforms.UWP")]
#endif

and in Generic.xaml : xmlns:vlc="libvlcsharp"

kakone avatar Aug 26 '22 10:08 kakone

I tried but can't get it to work (either it doesn't build or it crashes at runtime).

mfkl avatar Aug 29 '22 07:08 mfkl

If you have time to give it a try, it's much welcome @kakone :-)

mfkl avatar Aug 31 '22 10:08 mfkl

nice to see this being work on :) thx MAUI is comming :D

michalss avatar Sep 08 '22 14:09 michalss

I tried but can't get it to work (either it doesn't build or it crashes at runtime).

Part of the problem is that I can't find a way to import the namespace required for XmlnsDefinition for the UAP target (the WinUI net6 target is fine). Neither the System.Windows.Markup nor the Windows.UI.Xaml.Markup namespaces seem to accepted for UAP.

mfkl avatar Sep 12 '22 07:09 mfkl

@mfkl, can you share the content of your folder C:\Users\Martin\Desktop\vlc-3.0.18 ? 😄

kakone avatar Sep 13 '22 13:09 kakone

Part of the problem is that I can't find a way to import the namespace required for XmlnsDefinition for the UAP target

Yes, you are right, it doesn't work for the UAP target and I didn't find any workaround.

kakone avatar Sep 13 '22 15:09 kakone

Ok well this will have to do then. Thanks for trying.

mfkl avatar Sep 14 '22 03:09 mfkl

IMHO, renaming the namespace to a common namespace (like Windows) would be a better solution. I prefer to introduce a breaking change than keeping a namespace of a deprecated platform.

kakone avatar Sep 14 '22 09:09 kakone

is there any progress pls ? or we waiting for 3.0.18 still ?

michalss avatar Sep 28 '22 07:09 michalss

is there any progress pls ? or we waiting for 3.0.18 still ?

Waiting still. Pinging the PR will not make it go faster.

mfkl avatar Sep 28 '22 07:09 mfkl

IMHO, renaming the namespace to a common namespace (like Windows) would be a better solution. I prefer to introduce a breaking change than keeping a namespace of a deprecated platform.

Rebased and done.

mfkl avatar Oct 26 '22 07:10 mfkl

Forgot the Uno part, CI caught it. Will handle it soon.

mfkl avatar Oct 26 '22 10:10 mfkl

Forgot the Uno part, CI caught it. Will handle it soon.

Nice,. Maybe stupid question, but after this would be player working also with maui android target ?

michalss avatar Oct 26 '22 11:10 michalss

after this would be player working also with maui android target?

No this PR is about WinUI, not MAUI.

mfkl avatar Oct 27 '22 08:10 mfkl

libvlc 3.0.18 finally landed so we should be able to have a look at this (once I get some time...).

mfkl avatar Dec 05 '22 10:12 mfkl

Seems there is a small d3d11 leak when closing the WinUI sample

D3D11 WARNING: Live Producer at 0x000001DACAFE9580, Refcount: 8. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA1C5030, Refcount: 1. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA23A140, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C7BD00, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C7A5C0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C7AD80, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C788B0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA141D50, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA1C2090, Refcount: 2. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA8947B0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C81BF0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C82F50, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA894B90, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFD0D2FF0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C81240, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAF9C806A0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFD3A99A0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFD3A7EF0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFD3A7380, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFD3A6BE0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA173420, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFD3F47D0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFD3F2D90, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFA1C2FC0, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAC949F040, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: 	Live Object at 0x000001DAFBC8A070, Refcount: 0. [ STATE_CREATION WARNING #0: UNKNOWN]
D3D11 WARNING: Live                         Object :     25 [ STATE_CREATION WARNING #0: UNKNOWN]
DXGI WARNING: Live Producer at 0x000001DAF9C0FCB8, Refcount: 6. [ STATE_CREATION WARNING #0: ]
DXGI WARNING: 	Live Object at 0x000001DAF9C50800, Refcount: 3. [ STATE_CREATION WARNING #0: ]
DXGI WARNING: 	Live Object at 0x000001DAF9C4F500, Refcount: 1. [ STATE_CREATION WARNING #0: ]
DXGI WARNING: 	Live Object at 0x000001DAF9C4F040, Refcount: 1. [ STATE_CREATION WARNING #0: ]
DXGI WARNING: 	Live Object at 0x000001DAFA27FC20, Refcount: 1. [ STATE_CREATION WARNING #0: ]
DXGI WARNING: Live                         Object :      4 [ STATE_CREATION WARNING #0: ]

mfkl avatar Feb 21 '23 09:02 mfkl

Got it down to these few leaks.

DXGI WARNING: Live IDXGIFactory at 0x0000028A7CE326B0, Refcount: 4 [ STATE_CREATION WARNING #0: ]
DXGI WARNING: 	Live IDXGIAdapter at 0x0000028A7CEDC800, Refcount: 1 [ STATE_CREATION WARNING #0: ]
DXGI WARNING: 	Live IDXGIAdapter at 0x0000028A7CEDDFC0, Refcount: 1 [ STATE_CREATION WARNING #0: ]
DXGI WARNING: 	Live IDXGIAdapter at 0x0000028A7CEDD640, Refcount: 1 [ STATE_CREATION WARNING #0: ]
DXGI WARNING: Live                   IDXGIAdapter :      3 [ STATE_CREATION WARNING #0: ]
D3D11 WARNING: Live ID3D11Device at 0x0000028A71BE2EA0, Refcount: 2 [ STATE_CREATION WARNING #441: LIVE_DEVICE]

I don't see where they originate from, though.

mfkl avatar Feb 22 '23 08:02 mfkl

Hi @mfkl is it possible to download a Nuget "preview" package with this feature from somewhere? would be really nice, thanks a lot for your work!

Panda-Sharp avatar Mar 01 '23 10:03 Panda-Sharp

Hi, there is no preview for this as there are a few memory leaks. Help is welcome to fix them coz I can't find out where they come from.

mfkl avatar Mar 01 '23 10:03 mfkl

Hi, there is no preview for this as there are a few memory leaks. Help is welcome to fix them coz I can't find out where they come from.

Thanks for your reply, unfortunately I'm not able to help with these specific ones, I hope you'll figure it or someone more expert than me will be able to pint you out to the right direction, sorry :/

Panda-Sharp avatar Mar 01 '23 12:03 Panda-Sharp

Leak was identified and fixed in https://code.videolan.org/videolan/vlc/-/merge_requests/3441. This PR should be ready to go through, at least for a beta support package.

mfkl avatar Mar 22 '23 08:03 mfkl

Will this support both packaged and unpackaged winui3 apps?

insomniachi avatar Mar 22 '23 08:03 insomniachi

Will this support both packaged and unpackaged winui3 apps?

With some toolchain hacks, yes. Always had trouble running unpackaged WinUI apps, unrelated to libvlcsharp. image

mfkl avatar Mar 22 '23 09:03 mfkl