WebView icon indicating copy to clipboard operation
WebView copied to clipboard

M1 ARM Mac support

Open vadd98 opened this issue 2 years ago • 15 comments

Hi, I tried to open the WebView on a M1 Mac with ARM CPU but it doesn't work. Is there any way to run it on ARM Macs?

vadd98 avatar Dec 31 '21 18:12 vadd98

Hi,

It works with the Rosetta emulation. What error are you getting?

joaompneves avatar Dec 31 '21 19:12 joaompneves

I'll try to explain my whole situation. I'm developing a cross-platform app that needs to run on both Windows and Mac with both x64 and ARM cpu architecture support, with specific self-contained and architecture dependent builds. On x64 I have no problem, while on ARM I get crashes.

I noticed that on M1 Mac I don't get the dialog that asks me to install Rosetta (like explained here). I think that happens because the app is built for ARM, so Mac thinks there is no need to install Rosetta. Any ideas?

By the way, will there be any native support for ARM architectures for both Windows and Mac?

vadd98 avatar Jan 01 '22 14:01 vadd98

To work natively on Apple Silicon chips this project needs 2 upgrades:

  • CEF, the underlying browser engine, (CefGlue) needs to be upgraded to version 93+
  • .Net 6 - this is the first .net with M1 support

Have you tried installing Rosetta?

joaompneves avatar Jan 02 '22 19:01 joaompneves

At the moment I can't try with Rosetta because I don't have a M1 Mac, I received the feedback from a client that has one. By the way, I'll try to find a way to try it, maybe asking him to install directly the x64 version on his M1.

By the way, if you don't mind me asking, is there any plan to upgrade CEF and NET to the latest versions in order to support natively Apple Silicon chips?

vadd98 avatar Jan 03 '22 10:01 vadd98

I don't have an M1 also... so I can't assist on that now. We don't have plans yet to do the upgrade. .Net upgrade should be easy... CEF upgrade can give a little bit more troubles (it depends on CEF apis breaking changes).

joaompneves avatar Jan 03 '22 10:01 joaompneves

All clear, thanks. I'll let you know if I get any news

vadd98 avatar Jan 03 '22 10:01 vadd98

Is there any news on this ? I'm trying to create an native Mac ARM app with .net 6.0.

After building my app I receive the message "Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'WebViewControl.Avalonia, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format."

I don't know if this message is about the CEF framework or de WebView library.

I;ve managed to build a native CEF build. But this does not generate the libcef.dylib anymore, but the "Chromium Embedded Framework.framework". So I can't quite figure out how to implement this.

rickkock avatar Jul 13 '22 06:07 rickkock

Well, I still don't have Apple Silicon, so can't help on that. :(

joaompneves avatar Jul 13 '22 08:07 joaompneves

After building my app I receive the message "Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'WebViewControl.Avalonia, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format."

Having the same issue. I will do some more investigating and see if I can find a solution. I may be in over my head.

chrisg32 avatar Jul 20 '22 10:07 chrisg32

@rickkock I have managed to get it to run on Rosetta by publishing and osx-x64 version.

Rider publish profile

I cannot get it to launch from Rider/debug even with an osx-x64 or x64 build configuration. That is the next hurtle.

chrisg32 avatar Jul 20 '22 11:07 chrisg32

I've got it fully worked on M1 native now.

What I did was compiled both CefGlue (including the browser process etc.) and WebView from source on the M1 Mac

After that I've downloaded the corresponding version of CEF from https://cef-builds.spotifycdn.com/index.html#macosarm64:91.1.6

Form here I've extracted the libcef.dylib (renamed the "Chromium Embedded Framework" file from the "Chromium Embedded Framework.framework" directory) and copy it all to the output folder of my application.

rickkock avatar Jul 20 '22 12:07 rickkock

Hi @rickkock May I suggest you open a PR on CefGlue with those changes? Also you may find here the cef packaging scripts for macOS: https://github.com/OutSystems/cef.redist.osx

joaompneves avatar Jul 20 '22 14:07 joaompneves

Also according to this thread: version 93 was the first official version to support ARM64 on Apple Silicon chips.

joaompneves avatar Jul 20 '22 14:07 joaompneves

I didn't make any changes to CefGlue or WebView, I just compiled it on an M1 to create an anycpu library. For some reason the nuget package provides an x64 library. That's why the System.BadImageFormatException occurs.

I did the part of cef.redist script by hand, because I didn't know that there was a script for.

Also there is an arm64 build of CEF for the version 91.1.6. Witch is these same version used in the cef.redist.osx package. The only downside is that this is an beta version of CEF, but that it is also for the x64 version of OSX.

rickkock avatar Jul 20 '22 16:07 rickkock

There is.. but according to that thread, it might not be "stable", since the first version supported was 93. Was just suggesting submitting a PR because other people might want to use it. I dont have M1 so I cant provide a solution as of now.

joaompneves avatar Jul 20 '22 16:07 joaompneves

Hi, just to update on this thread: the current version of WebView in master supports ARM64 natively

alvesmiguel1 avatar Oct 10 '23 14:10 alvesmiguel1