airsdk / Adobe-Runtime-Support

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

[Windows] StageWebView with UseWebView2 system display zoom 150% #2920

Open Mintonist opened 10 months ago

Mintonist commented 10 months ago

Hi! Previously I used ANE NativeWebView or old AIR StageWebView for my game in payment process. I set viewPort like this: stageWebView.viewPort = new Rectangle(deltaX, deltaY, Starling.nativeStage.stageWidth-2*deltaX, Starling.nativeStage.stageHeight-2*deltaY);

And there were no problems with any Windows display zoom: 2023-11-15_172119

But with WebView2 on PC with 150% zoom it looks: 2023-11-15_172314

Starling.supportBrowserZoom and Starling.supportHighResolutions are true.

descriptor settings:

<initialWindow>
        <content>SWF file name is set automatically at compile time</content>
        <requestedDisplayResolution>high</requestedDisplayResolution>
        <visible>true</visible>
        <renderMode>direct</renderMode>
        <softKeyboardBehavior>none</softKeyboardBehavior>
        <depthAndStencil>true</depthAndStencil>
        <resizable>true</resizable>
        <systemChrome>standard</systemChrome>
        <maximizable>true</maximizable>
        <minimizable>true</minimizable>
        <minSize>480 320</minSize>
        <maxSize>1440 960</maxSize>
 </initialWindow>

Is it a AIR bug or I need to count zoom myself?

shaucky commented 10 months ago

I guess it's because it requested high-resolution settings… I remembered that i faced the same problem?

There is a property provided by AIR 50.0 that can help you calculate the scaled area, see: https://airsdk.dev/reference/actionscript/3.0/flash/display/Screen.html#contentsScaleFactor .I think i should have solved it this way…

Mintonist commented 10 months ago

@xiaoChi888 thanks! Ican do it, but there were no problem early (before WebView2), so @ajwfrost has said that they were investigating the possible issue.

2jfw commented 9 months ago

Have a look here: https://github.com/airsdk/Adobe-Runtime-Support/issues/1784#issuecomment-1072373640

You need to consider stage.contentsScaleFactor when applying the viewport.

Mintonist commented 9 months ago

Thanks! I know about it. But how we can know what version of WebView we use at runtime (old or new)? So I think viewport must work the same way in both cases.

2jfw commented 9 months ago

Not sure if this is the best approach but you could access the app-descriptor.xml from you app and check for

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

which will indicate that you are using the "new" webview.

Something like:

var appXML : XML         = NativeApplication.nativeApplication.applicationDescriptor;
var ns : Namespace       = appXML.namespace();
var windowsTag : XMLList = appXML.ns::windows;
var isWebView2 : Boolean = XML(windowsTag).children()[0] == "true";
trace("isWebView2 " + isWebView2);
Mintonist commented 9 months ago

But now it can be old WebView even if descriptor has <UseWebView2>true</UseWebView2> (for example Edge WebView2 has been removed or never installed)