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

[Windows] Second instance of StageWebView with UseWebView2 display "WebView2 Host" message with background #3577

Open
itlancer opened this issue Nov 21, 2024 · 0 comments
Labels

Comments

@itlancer
Copy link

Problem Description

Second (and susequent) instance of StageWebView with UseWebView2 display "WebView2 Host" message with background for Windows devices.
It breaks UX in a lot of cases and cause "artifacts" on window resizing.

Tested with multiple AIR versions, even with latest AIR 51.1.2.2 with different Windows 10 devices, different WebView2 versions, different AIR applications with different architectures (32/64-bit) and different privileges. Not sure about Windows 11.
Same issue in all cases.
There is no such issue with first StageWebView.
There is no such issue with other platforms.

Related issues:
#2946
#2920
#2852
#2832
#2831
#1854
#1493
#1492
#1428
#223
#143

Steps to Reproduce

Launch code below with any Windows device and resize application window fast. Two StageWebView instances always will be at the center of window.
Application example with sources and demonstration video attached.
windows_stagewebview_usewebview2_host_message_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.media.StageWebView;
	import flash.geom.Rectangle;
	import flash.events.NativeWindowBoundsEvent;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	
	public class WindowsStageWebViewUseWebView2HostMessageBug extends Sprite {
		private var stageWebView:StageWebView;
		private var stageWebView2:StageWebView;
		
		public function WindowsStageWebViewUseWebView2HostMessageBug() {
			addEventListener(Event.ADDED_TO_STAGE, addedToStage);
		}
		
		private function addedToStage(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			var rect:Rectangle = stage.nativeWindow.bounds;
			var contentsScaleFactor:Number = stage.contentsScaleFactor;
			
			stageWebView = new StageWebView({mediaPlaybackRequiresUserAction:false});
			stageWebView.loadURL("https://www.bbc.com/");
			stageWebView.viewPort = new Rectangle(0, rect.height / 4 * contentsScaleFactor, rect.width / 2 * contentsScaleFactor, rect.height / 2 * contentsScaleFactor);
			stageWebView.stage = stage;
			
			stageWebView2 = new StageWebView({mediaPlaybackRequiresUserAction:false});
			stageWebView2.loadURL("https://airsdk.harman.com/");
			stageWebView2.viewPort = new Rectangle(rect.width / 2 * contentsScaleFactor, rect.height / 4 * contentsScaleFactor, rect.width / 2 * contentsScaleFactor, rect.height / 2 * contentsScaleFactor);
			stageWebView2.stage = stage;
			
			stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, windowResize);
		}
	
		private function windowResize(e:NativeWindowBoundsEvent):void {
			var rect:Rectangle = e.afterBounds;
			var contentsScaleFactor:Number = stage.contentsScaleFactor;
			
			stageWebView.viewPort = new Rectangle(0, rect.height / 4 * contentsScaleFactor, rect.width / 2 * contentsScaleFactor, rect.height / 2 * contentsScaleFactor);
			stageWebView2.viewPort = new Rectangle(rect.width / 2 * contentsScaleFactor, rect.height / 4 * contentsScaleFactor, rect.width / 2 * contentsScaleFactor, rect.height / 2 * contentsScaleFactor);
		}
	}
}

Actual Result:
Below second (right) instance of StageWebView you will see "WebView2 Host" message with gray background.
Also you can notice some artifacts and sometimes StageWebView instance will be displayed partially out of window:
image

Video demonstration:

windows_stagewebview_usewebview2_host_message_bug.mp4

Expected Result:
Second (right) instance of StageWebView will be displayed without "WebView2 Host" message, gray background and without artifacts.

Known Workarounds

none

@itlancer itlancer added the Bug label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant