Follow-up report about the WinRT port

29 April 2013

News

Hello,

Like last post, I’ve spent too much time working on VLC than writing updates and communicating, and I’m sorry again.

We are still working a lot of time, with almost a couple of persons spending most of their time on the WinRT port of VLC media player.

The biggest issue is that we have not managed to pass the store validation yet, because the VLC backend is not ready yet. I’ll explain in this blog post where we are.

VLC backend on WinRT

Reminder: So, the core of VLC and most of the modules, named libVLC, are the target to adapt to run on WinRT. The UI will integrate this core to show the videos.

As I previously explained, the build process of VLC is not integrated with Windows Tools, notably Visual Studio, because VLC uses Unix Tools to run on all platforms. This is one of the reasons why VLC media player works on Windows, Linux, BSD, Solaris, iOS, Android, OS/2 and so many other operating systems.

The main objective of the KickStarter was the compliance of this core to the WinRT Store Application limitations. We’re almost there, but not quite.

The issues we were facing with the compliance were mainly 2 things:

  • Extra Security,
  • Forbidden APIs.

The security enforcements (SafeSEH, packagedlibraries) where quickly done (and backported to the main VLC port). The forbidden symbols were a bit more complex.

Forbidden calls

When we started the project, we had over 600 unique symbols (Windows API calls) used in VLC, for a total of over 15000.

We are now at 16 left. And 32 more if we activate the networking code. This is cool, but not enough, since we must be at 0 to enter the store.

I’ll explain now how we did it.

Simple symbols replacements

Some symbols were easy to replace, when you knew that you are targeting only Windows 8, because they had some similar methods.

So, for each symbol, we provided a replacement with a newer API. This was quite long, but easy to do :)

You can see the result of our work here: mingw-w64 code.

Removal of code and Unicode

The second part was to remove some code in VLC that was not meant to be used in WinRT mode; this was mostly the code for the Console, the multimedia timers and some NT services. This improved the port of VLC media player for Windows, not only the one on WinRT.

We also removed some code from libVLC to move it to VLC, when it made sense. This is a good move for libVLC, in general.

Finally, we moved all the code of VLC and the dependencies (8 millions LoC) to UNICODE and Wide Chars. Once again, a task not too difficult, but a bit boring and long.

Most of that part was done mid-March. Then we hit a wall.

MSVCRT

The wall is called MSVCRT, aka Microsoft C Runtime, the equivalent of the libc, the C standard library,

Every version of Visual Studio and Windows comes with a new version, with version numbers from 2.0 to 11.0. It is often a dependency headache for big projects. Most open source projects use the old version named msvcrt.dll, the version 6.0.

But on WinRT, one MUST use MSVCRT 11.0 in order to pass the validation. This meant that we had to modify our compiler and toolchain to be able to link with this version.

This took us weeks of work, reading documentation, testing, asking Microsoft, doing it step by step and finally arriving to the result.

First, we had some mismatch between Debug and Release versions of the libraries when trying the validation. But as we were doing it manually, it was quite hard to understand what was going on, and the documentation was very scarce.

And then, running the application with MSVCRT 110 was just crashing without meaningful messages or usable debug reports or crashes.

When we asked Microsoft, some engineers told us that this could not possibly succeed, since the validation would not allow application compiled with 3rd party compilers to link with MSVCRT110. We did not want to believe them, since this would have killed the project.

And, they were wrong. We did it, but this took us way more time than anything we had anticipated. The final work was shared and integrated in our toolchain, Mingw-W64. All other open source applications will benefit from that, from now on.

COM RoAPI

So, the final piece is composed of symbols that only have replacements using the WinRT APIs.

Those WinRT APIs are a bit like extensions of Windows COM APIs. They work in a similar way, and are usable with methods similar to CoCreateInstance, named RoActivateInstance. However, they are not the same. People using Visual Studio, use a language named C++/CX that has a bit of magic to hide all the details.

But, of course, we need Visual Studio to use C++/CX. And we have GCC, targeting C code :D

Again, accessing those APIs directly from C code compiled with GCC should not be possible (according to some engineers), but we have been trying that path for quite a bit of time.

2 weeks ago, we had a good success: we were able to call a simple functions from a sample code, using RoActivateInstance. So, the hardest part was done.

What we are doing now is just rewriting the Microsoft WinRT headers and adapting the toolchain to munch those and call those symbols. We’re working full time on that part!

Conclusion: tl;dr

It’s been a hard time working on this port, with many more technical issues than expected. Therefore, we’ve been slower than expected.

We’ve done things that people (even from Microsoft) advised us against, and so far we’ve passed all the issues. So a great outcome is arriving!

We have a bit of work still to go on rewriting the headers to call the new WinRT APIs, and kill the remaining 16 symbols. We’re working full time to fix those! :)

Jean-Baptiste Kempf

Comments

  1. On 8 May 8080, 3:08 by aditalle

    I love VLC, and we haven’t got an update in a while, so how are things going and when should the app be expected?

  2. On 6 May 6060, 11:56 by Dkvam

    Thank you for Your great effort in doing this:)
    My Surface RT need a proper video player

  3. On 6 May 6060, 1:38 by alexis

    Any new news on release date or when it could be on the windows store. Just got an RT from MS event. And its totally useless without VLC!!!

  4. On 30 May 30300, 6:11 by Jean-Baptiste Kempf

    @Vic: I know, I was at the //build/ conference…

    I am not sure this is enough, and this might need a bit more work. And the compiler will be out in 6 months…

  5. On 30 May 30300, 6:10 by Jean-Baptiste Kempf

    @inches: yes it should be using D3D11.1 in D3D9 mode. And, yes, I hope it will be working on Windows XP, so I will merge that on the main line.

  6. On 30 May 30300, 6:07 by Vic

    Just to let you know (in case you haven’t been made aware of yet) Herb Sutter announced new C99 support for VS2013 preview that enables FFMPEG to compile with it. He specifically mentioned FFMPEG on stage (Build http://channel9.msdn.com/).

    Let us know if this will make some of the pending problems gone.

    Keep up the good work :)

  7. On 30 May 30300, 6:05 by inches

    I suppose this port will use D3D 11.1 feature level 9.1 for video rendering, as required by Surface RT (windows phone 8 uses feature level 9.3).
    Will this be a Windows RT specific change, or are you going to merge this in the main VLC trunk?
    Normally, D3D 11 feature level 9.1 allows applications to run on Windows XP with D3D9 (that’s the reason for these feature levels), so you could have one code for any Windows version.

  8. On 28 May 28280, 11:59 by Jean-Baptiste Kempf

    @muhkuh because VLC and dependencies don’t compile with VS limited C support.

  9. On 28 May 28280, 10:13 by muhkuh

    Just curious: Why not just use Visual Studio to build on Windows 8 instead of gcc? Wouldn’t that be easier than trying to jump through all those loops?

  10. On 15 May 15150, 2:45 by Bryan

    Waiting with bated breath for VLC RT! It’ll probably be the killer app for Windows RT. Given all the problems with the platform and the abysmal adoption rate, wonder why Microsoft didn’t choose to fund this brilliant effort. They’d really have done themselves a huge favor if there was a program like VLC available for Windows RT right from Day 1. Although perhaps it’s better that Microsoft has no control over this. Go VLC team!

  11. On 13 May 13130, 4:53 by Keith Jo

    Great work guys. U should also be on microsoft payroll

  12. On 12 May 12120, 1:30 by andy

    This is fantastic news. Kudos for all the effort you’re putting in to this. Much appreciated by pretty much everyone in the world!

  13. On 11 May 11110, 10:39 by Johannespreekt

    Good job guys!

    I still get the chills from a project I worked on while reading your post, been there done that when a financial institute decided to move some legacy code to use the latest API’s.

    Keep up the good work, love to see it appear on my Windows Phone 8, good luck to the finish!

  14. On 11 May 11110, 8:23 by Brandon

    Great to see this work progressing and that you’re contributing valuable learning and infrastructure back to the community.

    As someone who used to be a developer at Microsoft and worked a lot on Windows 8/RT, I must say I’m confused that anyone would say it’s “impossible” to use the WinRT ABI from C (or vanilla C++). After all, it is in an ABI, there’s really no reason at all it wouldn’t work. It’s designed like that for a reason! There may not be as many conveniences for raw C developers as there were in classic COM (i.e. I don’t think WinRT IDL includes C-compatible symbols) but those are always just that, conveniences.

    Anyway, glad to see the update. Good luck with the rest of the project!

  15. On 11 May 11110, 10:53 by J Gateway Price

    Has anyone noticed any audio playback problems on 3gp video files with VLC 2.0.6? I appear to be getting gaps in the playback (sometimes the playback is virtually inaudible). QuickTime & VLC 2.0.5 work perfectly fine.

  16. On 11 May 11110, 4:02 by Cornelius

    Keep up the great work! You’ll make it happen.

  17. On 10 May 10100, 6:13 by Devman

    You are my heroes!. I love VLC. Can’t await to use it on my Surface RT.

  18. On 10 May 10100, 4:28 by CX1

    Great work.

  19. On 10 May 10100, 1:11 by Jean-Baptiste Kempf

    @Alex: I’ll do so today.

  20. On 10 May 10100, 9:53 by Alex

    Thanks for the update, glad that you didn’t give up after running into so many hurdles, you should feel proud that you managed to accomplish things that the microsoft engineers didn’t think were even possible. is it still on track for a late June release date, or are we looking at a July release date?

    Also, I suggest posting this update to kick starter, a lot of the backers are getting impatient because of lack of updates. Maybe let whoever runs the VLC page to retweet your tweet, so it doesn’t get lost like one of your previous shorter updates :)

    Thanks,
    I and many others appreciate all the work that has gone into this, thank you so much for bringing VLC to windows Tablets! :)