zahmadsaleem / revit-webview2-demo

WebView2 Demo project for Autodesk Revit. Build UIs for Revit with your favorite web framework.
MIT License
59 stars 10 forks source link

WebView2 Screen goes blank / white #3

Open cancunvisual opened 2 years ago

cancunvisual commented 2 years ago

Tried to compile and run as-is in several ways with windows 10 and 11 with visual studio 2019 - 2022 inside Revit 2021-2022 but i get always blank or white screen inside the plugin screen.

Already downloaded all recomended Wpf / WebView2 from microsoft and a single standalone wpf application works well .... yet inside Revit doesn't. Any clues ??? .

cT4001 commented 2 years ago

also had that issue with the blank webview2.

After loooong (and frustrating) research, I found out, that visual studio is configured, to force revit to start in english.

grafik

But if you had installed the lasted edge in another language (for me its german) then the webview2 component remains blank.

After removing the "/language ENU" in debug settings, revit starts in system language (for me its german) and the component isn't blank anymore...

KonradZaremba commented 2 years ago

I have the same problem. Unfortunately, a change of command doesn't do the trick. UI app is active and it can be accessed via a browser. Do you have any other clue why it might not run the webview2 page?

KonradZaremba commented 2 years ago

Ok. Found out by accident. As it turned out it was the admin rights.

cancunvisual1 commented 2 years ago

Well thanks for support ... i went through it and i'm not confident about WebView2. What if you don't have admin rights or if the installation process gets somewhere else beyond just installing the plugin. I mean ... usability comes first from the installer and if there are several more steps required to make it work ... you are droping down more than half or your potential customers.

That's why in my conclusion is ... if you want create a plugin in Revit with browser interface ... keep it at the Cefsharp version whatever is already setup in revit ... works but it doesn't have the choice for updating nor offering the latests features of Cerf.

Or if you need something else safer / stronger ... create a side app with IPC. Maybe is a bit more complex but for me also just works.

May be it would be interesting to try if WevView2 could run inside the side app as a plugin and then make it embeddable.

Take a look at this: https://thebuildingcoder.typepad.com/blog/2019/04/set-floor-level-and-use-ipc-for-disentanglement.html#6

KonradZaremba commented 2 years ago

What if you don't have admin rights or if the installation process gets somewhere else beyond just installing the plugin

Sure this is actually quick thing to fix. As it turned out reason you need admin rights is this bit:

https://github.com/zahmadsaleem/revit-webview2-demo/blob/master/RevitWebView2Demo/WebViewPage.xaml#:~:text=%3Cwv2%3ACoreWebView2CreationProperties%20x%3AKey%3D%22EvergreenWebView2CreationProperties%22%20UserDataFolder%3D%22C%3A%5Ctemp%22%20/%3E

Path to for UserDataFolder is set as c:/temp. If you change it to path that doesn't need admin rights to access then it works fine. I personally use APPDATA folder where RVT add are placed.

benwwchen commented 11 months ago

What if you don't have admin rights or if the installation process gets somewhere else beyond just installing the plugin

Sure this is actually quick thing to fix. As it turned out reason you need admin rights is this bit:

https://github.com/zahmadsaleem/revit-webview2-demo/blob/master/RevitWebView2Demo/WebViewPage.xaml#:~:text=%3Cwv2%3ACoreWebView2CreationProperties%20x%3AKey%3D%22EvergreenWebView2CreationProperties%22%20UserDataFolder%3D%22C%3A%5Ctemp%22%20/%3E

Path to for UserDataFolder is set as c:/temp. If you change it to path that doesn't need admin rights to access then it works fine. I personally use APPDATA folder where RVT add are placed.

Tried this without luck. Could you please try changing it back to C:\temp to see if it still works? Thanks.

ZTXeng commented 7 months ago

Hello, sorry to bother you after several days. Have you resolved this issue now? I am currently troubled by this

尝试在 Revit 10-2022 中使用 Windows 10 和 11 以及 Visual Studio 2019 - 2022 按原样编译和运行,但我在插件屏幕内总是出现空白或白屏。

已经从微软下载了所有推荐的 Wpf / WebView2,并且单个独立的 wpf 应用程序运行良好......但在 Revit 中却没有。任何线索???. Hello, sorry to bother you after several days. Have you resolved this issue now? I am currently troubled by this

ZTXeng commented 7 months ago

What if you don't have admin rights or if the installation process gets somewhere else beyond just installing the plugin

Sure this is actually quick thing to fix. As it turned out reason you need admin rights is this bit: https://github.com/zahmadsaleem/revit-webview2-demo/blob/master/RevitWebView2Demo/WebViewPage.xaml#:~:text=%3Cwv2%3ACoreWebView2CreationProperties%20x%3AKey%3D%22EvergreenWebView2CreationProperties%22%20UserDataFolder%3D%22C%3A%5Ctemp%22%20/%3E Path to for UserDataFolder is set as c:/temp. If you change it to path that doesn't need admin rights to access then it works fine. I personally use APPDATA folder where RVT add are placed.

Tried this without luck. Could you please try changing it back to C:\temp to see if it still works? Thanks.

Did it run successfully?

cT4001 commented 7 months ago

for me another reason, beside the admin rights thing, was the missing webview dll's inside the revit plugin folder. This is only needed, if you install webview via nuget packages. Then you have to copy also the needed webview dlls(configure in build config view) from your project dir to the target revit plugin directory.

If you relay on globally installed webview, this is not needed...

for me the copy config looks like this...

copy "$(TargetDir)RevitPavePlugin.addin" "$(AppData)\Autodesk\Revit\Addins\2023" mkdir "$(AppData)\Autodesk\Revit\Addins\2023\RevitPavePlugin" copy "$(TargetDir)RevitPavePlugin.dll" "$(AppData)\Autodesk\Revit\Addins\2023\RevitPavePlugin"
copy "$(TargetDir)Microsoft.Web.WebView2.Core.dll" "$(AppData)\Autodesk\Revit\Addins\2023\RevitPavePlugin"
copy "$(TargetDir)Microsoft.Web.WebView2.Wpf.dll" "$(AppData)\Autodesk\Revit\Addins\2023\RevitPavePlugin" copy "$(TargetDir)Microsoft.Web.WebView2.WinForm.dll" "$(AppData)\Autodesk\Revit\Addins\2023\RevitPavePlugin" copy "$(TargetDir)Microsoft.Web.WebView2.DevToolsProtocolExtension.dll" "$(AppData)\Autodesk\Revit\Addins\2023\RevitPavePlugin"

juha-suokas commented 6 months ago

Running on Revit 2024, my root cause for blank screen was missing WebView2Loader.dll file.

When application was trying to open the web window in WebView2Window.xaml.cs, an exception System.DllNotFoundException: 'Unable to load DLL 'WebView2Loader.dll' (Exception from HRESULT: 0x8007007E)' was thrown.

This was due the WebView2Loader.dll not being copied to the Revit Addins folder after build.

I added additional line

xcopy "$(TargetDir)\runtimes" "$(AppData)\Autodesk\Revit\Addins\2024\RevitWebView2Demo\runtimes" /s /e /R /Y /I

to the Post-build event command line scripts. This properly copied the WebView2Loader.dll to $(AppData)\Autodesk\Revit\Addins\2024\RevitWebView2Demo\runtimes\win-x64\native\WebView2Loader.dll.

Additionally I also changed the Platform target in project build settings to x64:

image