Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Widevine support in Arm64 Windows #28318

Closed
mherrmann opened this issue Feb 6, 2023 · 27 comments · Fixed by brave/brave-core#18695
Closed

Add Widevine support in Arm64 Windows #28318

mherrmann opened this issue Feb 6, 2023 · 27 comments · Fixed by brave/brave-core#18695

Comments

@mherrmann
Copy link

mherrmann commented Feb 6, 2023

On Arm64 Windows, 32-bit Brave supports Widevine. But Arm64 Brave does not. The goal of this issue is to fix this.

This issue is important because it is a blocker for full native Arm64 support on Windows. For example, it is a pre-requisite for #29112.

A good URL for testing whether a browser supports Widevine is https://bitmovin.com/demos/drm.

Other browsers

Chrome doesn't offer a native Arm64 binary. Its 32-bit package supports Widevine.

Edge does offer a native Arm64 binary. It supports Widevine. Edge's installation directory contains a file called widevinecdm_proxy.dll. This gets loaded when a page with Widevine is opened in the browser. It's likely an Arm64 DLL that proxies the x86 Widevine implementation.

@mherrmann
Copy link
Author

@marcpems mentioned Arm64EC as a potential option for loading the Widevine x64 DLL.

@marcpems
Copy link

Worth noting up front that Arm64EC is only MSVC today will produce that ABI although the Clang-cl tool has some work to support it. For linking it must be MSVC linker today.

Arm64EC will compile and link both intel and Arm instructions to use and x64 compatible ABI, so calling directly from Arm code to intel will just work within the same binary or across binaries. That has the potential to allow the widevine x64 dll to load and run within an Brave browser built for Arm64EC. Performance of EC is much better than X64 emulated because all system calls (from Arm or X64) are direct and not going through a shim. Arm64EC is considered a native ABI for Windows on Arm.
https://www.youtube.com/watch?v=HmI6ip4o9as <- useful talk by Pedro on Arm64EC

Would this be an option to explore for Brave?

@mihaiplesa
Copy link
Contributor

@marcpems we'd need VS 2022 for that, right? We're currently on 2019.

@snickler
Copy link

@marcpems we'd need VS 2022 for that, right? We're currently on 2019.

It will work with Visual Studio 2019, but for the best compatibility VS 2022 is the way to go (especially when targeting Windows 11). You should see MSVC v142 -VS 2019 C++ ARM64EC build tools in Individual Components from the installer.

The Component ID for installing the workload is Microsoft.VisualStudio.Component.VC.Tools.ARM64EC. In Visual Studio 2019, it's still listed as experimental, but SHOULD work?

@mherrmann
Copy link
Author

Do I understand correctly that with Arm64EC we'd compile the entire Brave browser with MS's toolchains instead of clang? If yes, that seems like a hefty price to pay just to get one DLL working.

@snickler
Copy link

Do I understand correctly that with Arm64EC we'd compile the entire Brave browser with MS's toolchains instead of clang? If yes, that seems like a hefty price to pay just to get one DLL working.

See https://reviews.llvm.org/D134788

@mherrmann
Copy link
Author

Thank you @snickler. Could it be that LLD doesn't yet support Arm64EC? At least I'm getting unknown machine: 42561 when trying to build Brave with it:

FAILED: obj/brave/build/rust/cxx_cppdeps.lib
..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /lib /OUT:obj/brave/build/rust/cxx_cppdeps.lib /nologo /ignore:4221 /llvmlibthin /WX @obj/brave/build/rust/cxx_cppdeps.lib.rsp
obj/brave/build/rust/cxx_cppdeps/remap_alloc.obj: unknown machine: 42561

@snickler
Copy link

Thank you @snickler. Could it be that LLD doesn't yet support Arm64EC? At least I'm getting unknown machine: 42561 when trying to build Brave with it:

FAILED: obj/brave/build/rust/cxx_cppdeps.lib
..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /lib /OUT:obj/brave/build/rust/cxx_cppdeps.lib /nologo /ignore:4221 /llvmlibthin /WX @obj/brave/build/rust/cxx_cppdeps.lib.rsp
obj/brave/build/rust/cxx_cppdeps/remap_alloc.obj: unknown machine: 42561

Hmmm which triple are you using? Also, I wonder if this is more of a Rust issue?

@mherrmann
Copy link
Author

mherrmann commented Mar 17, 2023

which triple are you using?

arm64ec-pc-windows-msvc19.29.0. (I'm still on VS 2019.)

@snickler
Copy link

which triple are you using?

arm64ec-pc-windows-msvc19.29.0. (I'm still on VS 2019.)

I'm assuming it also causes issues if you strip off the msvc version?

@mherrmann
Copy link
Author

Yes. I need to check whether it's even possible to compile a simple Hello World program to Arm64EC with llvm.

@mherrmann
Copy link
Author

mherrmann commented Mar 17, 2023

It appears to me that at least parts of llvm don't yet support Arm64EC. The machine type 42561 in the error above is A641 in Hex, which is IMAGE_FILE_MACHINE_ARM64EC. The error message comes from https://github.com/llvm/llvm-project/blob/72e8b286f03c7f6bacbec10ca9883f77d482284c/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp#L173, which clearly refuses to handle that case.

@snickler
Copy link

It appears to me that at least parts of llvm don't yet support Arm64EC. The machine type 42561 in the error above is A641 in Hex, which is IMAGE_FILE_MACHINE_ARM64EC. The error message comes from https://github.com/llvm/llvm-project/blob/72e8b286f03c7f6bacbec10ca9883f77d482284c/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp#L173, which clearly refuses to handle that case.

Well Darn, it DOES seem that's the case for llvm-lib.

There's a PR for it, which makes me wonder just which parts of llvm support targeting arm64ec since there's many references to it in the source, along with the referenced urls showing such.

https://reviews.llvm.org/D143541

@mherrmann
Copy link
Author

Yes, that PR seems to add the constant precisely to the place I linked to. I wonder whether they will merge it soon, whether that is the only change that's missing, and then how stable/production ready it will be.

@niyas-sait
Copy link

Qualcomm is working on adding ARM64EC support to LLVM.

https://discourse.llvm.org/t/initial-patches-for-arm64ec-windows-11-now-posted/62449

I've reached out to Qualcomm and they have asked if we have any build recipes for Brave available so they can try to validate the implementation.

@mherrmann
Copy link
Author

mherrmann commented Mar 21, 2023

@nsait-linaro yes - follow the instructions at https://github.com/brave/brave-browser/ and additionally install MSVC v142 -VS 2019 C++ ARM64EC build tools in Visual Studio 2019. Before you do npm run build, replace arm64-windows in a few .gn files by arm64ec-windows in src/. Then do npm run build -- --target_os=arm64. Feel free to ping me with any follow-up questions.

@mherrmann
Copy link
Author

Comment from Pedro Justo about how Edge does it with Widevine:

You can't do that in the same process. The x64 DLL can't load in the Arm64 Classic process - period. Your "proxy" must involve another process and use IPC. In the Arm64 process load an Arm64 DLL + Create an Arm64EC EXE to load your x64 DLL + use IPC mechanisms like RPC or DCOM to communicate between them. This is what Arm64 Edge does with Widevine, for example.

@mherrmann
Copy link
Author

There seems to be movement on the Chromium side for Widevine Windows Arm64 support: chromium/chromium@77efb41

@snickler
Copy link

There seems to be movement on the Chromium side for Widevine Windows Arm64 support: chromium/chromium@77efb41

And this is the latest widevine binary for win-arm64!

https://dl.google.com/widevine-cdm/4.10.2557.0-win-arm64.zip

@mherrmann
Copy link
Author

mherrmann commented Apr 3, 2023

That's great! And I just tested that the binary can in fact be loaded into Arm64 Brave :) At the moment, this is a manual process. We need to make it so it happens automatically for users.

@niyas-sait
Copy link

That's great! And I just tested that the binary can in fact be loaded into Arm64 Brave :) At the moment, this is a manual process. We need to make it so it happens automatically for users.

Great news! @mherrmann just to confirm, this probably means we are not blocked on ARM64EC support for LLVM? And #29112 is no longer relevant

@mherrmann
Copy link
Author

@nsait-linaro

this probably means we are not blocked on ARM64EC support for LLVM?

As a general statement, I'd say this is correct. More specifically, we no longer need Arm64EC for Widevine. We may still decide to use it for on-demand updates (see #28380). But I'd say that's unlikely.

And #29112 is no longer relevant

That's not correct. #29112 is the fix Microsoft are using for #28380, and I think we should follow it.

@niyas-sait
Copy link

Sorry I meant the windows update issue with github.com/google/omaha are no longer relevant as we can always install arm64 binaries.

That's not correct. #29112 is the fix Microsoft are using for #28380, and I think we should follow it.

@mherrmann
Copy link
Author

Yes. :)

@niyas-sait
Copy link

@mherrmann @mihaiplesa Just wanted to follow up on the Windows Arm64 status. Any further updates on Widevine support?

@mherrmann
Copy link
Author

@nsait-linaro we've had some other more important issues come up. We've not forgotten about this and will update this issue as we make progress.

@MadhaviSeelam
Copy link

MadhaviSeelam commented Sep 14, 2023

Verification PASSED using

Brave | 1.59.86 Chromium: 117.0.5938.62 (Official Build) beta (arm64)
-- | --
Revision | 3c4c1c3b2eef0fcbe8485c67e1df504942deadca
OS | Windows 11 Version 22H2 (Build 22621.2283)

Bitmovin.com - PASSED

  1. Installed 1.59.86
  2. launched Brave
  3. visit https://bitmovin.com/demos/drm in a new tab page
  4. confirmed I got prompted to Install and run Google Widevine
  5. clicked Allow
  6. played the video for protected DRM stream
  7. opened brave://components
  8. confirmed Widevine Content Decryption Module is loaded
  9. confirmed widevinecdm_proxy.dll is loaded when Widevine is installed

Confirmed the content was streamed in High-Definition (HD) quality (through visual inspection)

step 4 step 6
image image
brave://components widevinecdm.dll
image image

Netflix - PASSED

1.new profile
2. launched Brave
3. loaded netflix.com
4. clicked on the Sign In link
5. entered my credentials
6. clicked on the Sign In button
7. confirmed I got prompted to Install and run Widevine
8. clicked Allow
9. clicked on Brave QA avatar
10. played Animal Apes
11. confirmed Widevine Content Decryption Module is loaded
12. confirmed widevinecdm_proxy.dll is loaded when Widevine is installed

Confirmed the content was streamed in High-Definition (HD) quality (through visual inspection)

example example
image image

Hbomax.com - PASSED

  1. new profile
  2. launched Brave
  3. loaded hbomax.com
  4. clicked on the Sign In button
  5. clicked Sign in to your account
  6. finally signed in
  7. clicked on my QA avatar
  8. clicked on TinytoonsLooniversity to play
  9. confirmed I was prompted to Install and run Widevine
  10. confirmed Widevine Content Decryption Module is loaded
  11. confirmed widevinecdm_proxy.dll is loaded when Widevine is installed

Confirmed the content was streamed in High-Definition (HD) quality, through visual inspection

example example
image image

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