airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
206 stars 11 forks source link

Possible Issue With StageWebView Using Latest Version Of AIR SDK #2172

Closed G-Powder closed 2 years ago

G-Powder commented 2 years ago

Hi everyone.

I was just wondering if anyone has experienced a similar problem. We have an AIR desktop application and we are using the latest version of the SDK ( version: 33.1.1.929 )

We are also using the latest version of the runtime. The problem we are having is loading certain web pages when implementing StageWebView. We are currently testing on Windows 11.

There is a certain web page that we need to load into our application that requires MS Edge to run the JavaScript. However no matter what we do, we can not get the AIR application to utilize the MS Edge engine when loading the page.

It is consistently using an older Internet Explorer engine and the JavaScript will not fire. In some cases it won't load the web page at all. Below is a very simple code example of what we are using which refuses to work.

/------------------------------------------------------------------------------------------ import flash.events.; import flash.system.;

var webView:StageWebView; webView = new StageWebView(true); webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight); webView.stage = this.stage; webView.addEventListener(flash.events.Event.COMPLETE, webViewComplete); webView.loadURL('https://www.thewebaddress.com/test.html');

function webViewComplete(e:Event):void { trace('Success'); } /------------------------------------------------------------------------------------------

We have also attempted using both with no success: new StageWebView(true); new StageWebView(false);

In addition, after some research, we also tried installing the Edge WebView2 component from Microsoft on the computer running the AIR application and then including this in the descriptor file:

<windows> <UseWebView2>true</UseWebView2> </windows>

Again with no success. The page will either not load at all, or will continue to use an older IE engine that will not render the page properly.

If anyone has experienced a similar issue your insight would be appreciated.

Thanks all.

ajwfrost commented 2 years ago

Having that UseWebView2 flag, and the Edge WebView2 component installed, are the main dependencies .. the runtime should then be able to instantiate the new webview; if it fails to find it, it will fall back to the IE-based WebBrowser control.

Can you check in your registry that you have a value under: SOFTWARE\Microsoft\EdgeUpdate\Clients{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5} with "location" and "pv" fields? Then if you look in Windows under the folder given by "location", there should be a subfolder with the value from "pv", then "EBWevView", then "x86" if you're using AIR in normal 32-bit mode, then a file "EmbeddedBrowserWebView.dll"

If that exists, we are then loading the library and looking for a symbol called "CreateWebViewEnvironmentWithOptionsInternal" - I don't suppose you could use Dependency Walker to see if that symbol exists? or, let us know what the version code is that you see under "pv" and we can try to get the same version down on a Win11 machine..

thanks

G-Powder commented 2 years ago

Hi Andrew.

Thanks for the quick response. So we checked the registry for that key.

The location is actually here on our Windows 11 machine: Software\Microsoft\EdgeUpdate\ClientState\F3017226-FE2A-4295-8BDF-00C3A9A7E4C5

Not sure if that matters in this case, however there are no "location" or "pv" fields which is strange. We double checked and the WebView2 component was successfully installed using the Evergreen Bootstrapper.

Any further help would be appreciated.

Thanks.

ajwfrost commented 2 years ago

Hi

So having looked on my newest machine, it seems I only have the webview available in 32-bit mode (I've not installed it, it's just been set up like this out of the box...)

Registry key is therefore including the "WOW6432Node" section when I view this in the registry editor:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}

Can you also check where the library actually is? So for me: C:\Program Files (x86)\Microsoft\EdgeWebView\Application\105.0.1343.53\EBWebView\x86\EmbeddedBrowserWebView.dll Curiously though, there's an x64 folder there even though there's no registry key available in the 64-bit registry. So we may have a problem with detection when running AIR in 64-bit mode, I'll check on that..

G-Powder commented 2 years ago

Hey Andrew,

Ok so we found the registry key. It exists under the same path as yours above.

The library path is also the same for us here: "C:\Program Files (x86)\Microsoft\EdgeWebView\Application\105.0.1343.53\EBWebView\x86\EmbeddedBrowserWebView.dll"

I did see the x64 folder as well.

We also double checked that we are using the latest SDK and that it's properly installed. I think you may be right in regard to the 64-bit mode detection. No matter what we do, we can't the app to run using WebView2.

If you can confirm the detection issue for us we would appreciate it as we need to continue development on our application soon.

Thanks for all your help.

ajwfrost commented 2 years ago

So just to double-check from the above - are you running this in 64-bit mode? And does it load the library if you did use 32-bit?

ajwfrost commented 2 years ago

Hmm... for us it's still working in 64-bit mode. The registry key is read with "KEY_WOW64_32KEY" which means we'll always be looking under that "WOW6432Node" entry.

So the issue seems to be something else .. we can put together a test build for this to find out where it's failing, are you able to confirm whether you use 32-bit or 64-bit and also that you'd be able to use Adobe Scout to capture some logs from this?

thanks

G-Powder commented 2 years ago

Hey Andrew.

We are running in 64-bit mode.

Just for a test, can you try loading this URL using WebView2? https://www.iris-soft.net/files/backend/routing/trimble_map.html

Here is the code we are using for this test:


import flash.events.; import flash.system.;

var webView:StageWebView; webView = new StageWebView(true); webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight); webView.stage = this.stage; webView.addEventListener(flash.events.Event.COMPLETE, webViewComplete); webView.loadURL('https://www.iris-soft.net/files/backend/routing/trimble_map.html');

function webViewComplete(e:Event):void { trace('Success'); }

It's a simple test page that should load a map. The loading of the map is what is failing. It works if you open it directly in the MS Edge browser.

I just want to make sure this is not an issue on the map providers' side. I'll run Adobe Scout today and get you the logs as well.

Thanks again for all your help.

ajwfrost commented 2 years ago

Works for me in 32-bit mode.. and in 64-bit. Although in all cases, it looks like it's night-time...

In terms of the logs, I was going to add a bit more output/debugging into the AIR runtime so that we can see what's happening when it tries to open the Edge webview. So I'll post up a new DLL here shortly that you can use and that will output some extra trace to the Scout tool..

ajwfrost commented 2 years ago

Hi

So, below is a link to download a version of the runtime that should add extra debugging output that you can see from the Scout "trace log". When I try it, I get the below output:

AIRSDK: Creating a StageWebView control
Win32WebView2 - Checking if webview2 is enabled in app descriptor
Win32WebView2 - Found a setting for UseWebView2 = true
Win32WebView2 - UseWebView2 = true
AIRSDK: Attempting to use the Edge webview2
Win32WebView2 - constructor
Win32WebView2 - Getting library location from registry
Win32WebView2 - Found the registry key
Win32WebView2 - Found the registry values for location (C:\Program Files (x86)\Microsoft\EdgeWebView\Application) and version (105.0.1343.53)
Win32WebView2 - created library location of C:\Program Files (x86)\Microsoft\EdgeWebView\Application\105.0.1343.53\EBWebView\x64\EmbeddedBrowserWebView.dll

Win32WebView2 - attempting to load library: C:\Program Files (x86)\Microsoft\EdgeWebView\Application\105.0.1343.53\EBWebView\x64\EmbeddedBrowserWebView.dll
Win32WebView2 - library loaded successfully, getting creation function
Win32WebView2 - library loaded successfully, creation function = 00007FF820B8C710
Win32WebView2 - called creation function, result = 0x00000000
Win32WebView2 - checking if it loaded properly (000068A2002E4060)

If you're able to put this DLL into your AIR SDK, under the below folder, and then run the application, it should give you something similar or at least will tell us where it's going wrong... (please back up the DLL that's there, before copying over the top of it, so that you can restore it back to normal later!) runtimes\air\win64\Adobe AIR\Versions\1.0\

thanks

https://transfer.harman.com/message/I3IujhEn6VB6qTv1reLSYX

G-Powder commented 2 years ago

Hey Andrew.

You won't believe this. But we got it to work. Here's the deal. We were pretty sure everything was set up correctly with the runtime and the SDK.

During testing and loading of the Html page, we set up a series of JavaScript alerts so we could output what version of the browser engine the application was using along with other details to diagnose.

For example just simple alerts to display "navigator.userAgent". We removed the JS alerts on the page sample we sent you and it worked for you. We then tested again here after the removal and it worked for us as well.

There never was an issue firing off JavaScript alerts in the past using StageWebView with older IE engines. However in this case when adding something as simple as: alert('JS Alert Test');

The page won't render and display for us at all. When we remove it, the page loads correctly. If you try the URL directly in the browser, you'll see the alert fires first before the map loads.

But it won't when going through WebView2 in the AIR application.

Do me a favor and try loading this again: https://www.iris-soft.net/files/backend/routing/trimble_map.html

We added a simple alert('JS Alert Test'); to the page. Let me know if you see the alert fire and if map page load now.

I just want to see if you're getting the same result. Maybe it's some new security restriction on the Microsoft side but let me know if the page loads for you now.

Thanks much.

ajwfrost commented 2 years ago

Hi

That's odd because JS alerts work for me .. I just tried that page again and saw the pop-up in AIR (trying 50.0 and 33.1 in both 32-bit and 64-bit modes..)

I'm running via ADL (or adl64.exe) - are you doing the same or have you got a custom .exe file for this? Not sure it should really make a difference to the webview2 behaviour though..

I wonder if there's another way you can try hosting that webview2 control to test it out locally?

thanks

G-Powder commented 2 years ago

It is bizarre. No custom .exe is being used.

We tried going through ADL exe as well and directly through the Adobe Animate IDE, creating a quick AIR desktop app and publishing. It still fails to load with the additional JavaScript.

We also checked Firewall and Antivirus settings just in case. We'll try a few more tests but at least we know what was preventing it in this case. I'll also get the logs out of Scout so we can do a comparison.

Thanks

ajwfrost commented 2 years ago

Is it worth right-clicking and using "Inspect" to open up the dev tools? This works for me and I can then go to the console tab to check things and to enter new JS to get processed:

image

(On this site, right-click only gave me the menu when I was hovering over the "Trimble Maps" logo..)

thanks

G-Powder commented 2 years ago

Hey Andrew.

Ok, we finally got it to work. We did a reset of IE and rebooted. I've seen a reset help with other strange issues in the past. ( Not directly related to AIR )

This was definitely a weird one I have to say, but it looked to be more of an isolated problem. Thanks so much for all of your time and help investigating this.

You've been a great help.

Cheers..

ajwfrost commented 2 years ago

Glad you got it working, yes, bit of a weird one! thanks