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

WebView causes empty window popup and closes immediately #24933

Closed
jhastingsiii opened this issue Sep 25, 2024 · 14 comments
Closed

WebView causes empty window popup and closes immediately #24933

jhastingsiii opened this issue Sep 25, 2024 · 14 comments
Labels
blocked Work that is currently blocked partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with partner Issue or Request from a partner team platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@jhastingsiii
Copy link

jhastingsiii commented Sep 25, 2024

Description

This only started happening recently without any code changes, guessing maybe a browser or windows update has caused the problem? There never used to be any kind of flickering popup. If you don't set the source property on the web view, the popup doesn't occur. The popup is hard to see with the default window size, make the window size smaller to see it easier.

Steps to Reproduce

  1. New MAUI app
  2. New Page with a web view that has hardcoded source content
  3. Navigate to the new page

https://github.com/jhastingsiii/busted-maui-webview

Link to public reproduction project repository

No response

Version with bug

8.0.91 SR9.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

@jhastingsiii jhastingsiii added the t/bug Something isn't working label Sep 25, 2024
@drasticactions drasticactions added the s/needs-repro Attach a solution or code which reproduces the issue label Sep 26, 2024
@drasticactions
Copy link
Contributor

Can you please make a small repro project showing this? It makes it easier to establish the issue from a shared context in case anyone else can't.

@ITaluone
Copy link

ITaluone commented Sep 26, 2024

I think I have a related problem. I am developing two WinUI apps which both have approximately the same setup.

My app setup is as follows (the same for both):

  • WinUI app
  • App creates a system tray icon
  • App hides on startup; This is done in various places:
    • MauiProgram.cs -> ConfigureLifecycleEvents()
  builder.ConfigureLifecycleEvents(lifecycle =>
      {
#if WINDOWS
          lifecycle.AddWindows(lifecycleBuilder => lifecycleBuilder
              .OnPlatformMessage((window, _) =>
              {
                  if (!(IsStarting && ps.StartInSystemTray())) return;

                  GetAppWindow(window);

                  _appWindow.Hide();
              })
              .OnVisibilityChanged((_, args) =>
              {
                  if (IsStarting && ps.StartInSystemTray())
                  {
                      DisableStarting();
                      return;
                  }

                  if (!ps.Get<bool>(StorageKey.MinimizeToSystemTray)) return;

                  if (IsClosing || args.Visible)
                  {
                      App.ResizeSave();
                      return;
                  }

                  MinimizeToTray();
              })
              .OnWindowCreated(window =>
              {
                  // window.ExtendsContentIntoTitleBar = true; // https://github.com/dotnet/maui/issues/18773
                  GetAppWindow(window);

                  if (ps.StartAppMaximized() && _appWindow.Presenter is OverlappedPresenter p) p.Maximize();

                  _appWindow.Closing += (_, e) =>
                  {
                      e.Cancel = true;

                      if (ps.Get<bool>(StorageKey.DoNotQuitApp) && !ForceClose)
                      {
                          MinimizeToTray();
                          return;
                      }

                      SetClosing();
                      Application.Current?.Quit();
                  };
              }));
#endif
      });
  • The universal App.cs where I do some window resizing and such (and also check if it should launch in systray)

In the past, this setup prevents the app window to show at all on startup (just makes the systray icon (with H.NotifyIcon.Maui, btw) and nothing else, until the user opens the app by icon click.
This is the setup both share.

But since today or so (I can not tell since when exactly, because I stumbled upon this today the first time) a blank window pops up, size is approx. window height and the width approx. width/2.

What I tried:

  • I tried to debug this, but cannot find a point when this appears to happen.
  • I updated MAUI to 8.0.91 today, so I reverted this -> didn't help
  • I reverted back to the latest commit (aka release) -> did work the first recompile, but next recompile it is flickering again

Conclusion

I can not tell what had changed, but it seems that MAUI is not the only actor in the story, because when I start the already released and deployed apps it works as it should. Probably a race condition with WASDK/MAUI or .NET SDK or WebView2 runtime.

Edit: I managed to stop with a break point when the popup is open.

2024-09-26_14-38-34.zip
(this is a short screen cast, I didn't manage to upload the MP4 directly...

What really strange is: I can click behind it and open the context menu from a desktop icon (as example).

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Sep 26, 2024
@jhastingsiii
Copy link
Author

jhastingsiii commented Sep 26, 2024

Can you please make a small repro project showing this? It makes it easier to establish the issue from a shared context in case anyone else can't.

Yes, it wouldn't let me attach it to the original ticket for some reason, here it is.
MauiApp1.zip

@jhastingsiii
Copy link
Author

Hi @jhastingsiii. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Broken bot? Not only did I provide the steps for reproducing the problem, but I also provided the source code as well.

@ninachen03
Copy link

ninachen03 commented Sep 27, 2024

This issue has been verified using Visual Studio 17.12.0 Preview 2.0(8.0.91 & 8.0.3) 17.11.4 (7.0.101). Can repro this issue at windows platform.

@ninachen03 ninachen03 added platform/windows 🪟 s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Sep 27, 2024
@RuddyOne
Copy link

I have also started seeing this issue with no code change. Do we know what this issue is and any workaround/fixes for now?

@ITaluone
Copy link

As I said: I think MAUI is not to blame here. My apps are MAUI.Blazor apps, so every launch of an app launches WebView2 and revealing this issue at app startup immediately.

@rswilley
Copy link

I am having this same problem. Last week I didn't have this issue and with no code change I am seeing a flickering popup.

@MatthewKing
Copy link

I am having this same issue. No code changes.

@stephenquan
Copy link

stephenquan commented Oct 1, 2024

I was able to reproduce this with the following method:

  1. Create a new .NET MAUI starter app (the one with dotnet_bot.png)
  2. Add <MauiVersion>8.0.91</MauiVersion> underneath <UseMaui>true</UseMaui> in the app's csproj
  3. Add the following WebView to the MainPage.xaml
            <WebView
                HeightRequest="600"
                Source="https://github.com/dotnet/maui/issues/24933"
                WidthRequest="600" />

Here are 5 screenshots representing the different states I see the app go thru:

  1. Launch the app
  1. At approximately 2.8 seconds we see a blank MainPage.xaml appear
  1. At approximately 3.1 seconds we see an unexpected empty window popup (full height, half width, left aligned) and it stays visible for approximately 0.1 seconds
  1. At approximately 3.3 seconds the MainPage.xaml goes to gray for approximately 0.1 seconds
  1. At approximately 3.4 seconds the MainPage.xaml goes back to white and takes a further 1.4 seconds to fully populate

@stephenquan
Copy link

I tried the workaround from MicrosoftEdge/WebView2Feedback#4834 (comment) by adding:

Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--window-size=0,0 --window-position=20000,20000");

to my App.xaml.cs before InitializeComponent(); and it appears to obfuscate the empty window popup. This might be a satisfactory workaround that can be put in place until this issue is fixed.

@PureWeen PureWeen added partner Issue or Request from a partner team partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with labels Oct 2, 2024
@PureWeen PureWeen added this to the .NET 9 SR1 milestone Oct 2, 2024
@PureWeen
Copy link
Member

PureWeen commented Oct 2, 2024

Adding this to our .NET8 SR9.2 milestone for tracking purposes.

It looks like this is a runtime issue
MicrosoftEdge/WebView2Feedback#4834 (comment)

@PureWeen PureWeen modified the milestones: .NET 9 SR1, .NET 8 SR9.2 Oct 2, 2024
@Redth
Copy link
Member

Redth commented Oct 2, 2024

Thanks for the reports and the repro step details.

This one is unrelated to MAUI and is reproduceable with a plain .NET WinUI3 app. We're waiting on an upstream fix for the issue already mentioned here: MicrosoftEdge/WebView2Feedback#4834

@Redth Redth added blocked Work that is currently blocked and removed s/needs-attention Issue has more information and needs another look labels Oct 2, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR9.2, .NET 9 SR1 Oct 8, 2024
@jhastingsiii
Copy link
Author

This issue is fixed now with the latest Edge release Version 130.0.2849.46 (Official build) (64-bit)

@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Work that is currently blocked partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with partner Issue or Request from a partner team platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

10 participants