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

WebView2 blocks mouse input to the application after typing too fast #3266

Closed
ghord opened this issue Dec 21, 2022 · 55 comments
Closed

WebView2 blocks mouse input to the application after typing too fast #3266

ghord opened this issue Dec 21, 2022 · 55 comments
Labels
area-Input area-WebView bug Something isn't working Status: Fixed internally The issue has been fixed but has not yet shipped in a release.
Milestone

Comments

@ghord
Copy link

ghord commented Dec 21, 2022

Describe the bug

WebView2 freezes mouse input when typing too fast.

Steps to reproduce the bug

  1. Create new application with WebView2 control
  2. Set source to any page with input (google/bing)
  3. Type in input very fast
  4. Mouse input to whole app freezes (notice unchanging cursors). Only keyboard input continues to work.

Expected behavior

WebView2 continues to work normally

Screenshots

Animation

NuGet package version

Windows App SDK 1.2.1: 1.2.221116.1

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

This does reproduce on both packaged and unpackaged apps.

This does not reproduce on versions 1.1.x.

This issue occurs in every 1.2.x version I've tried.

@applefanbois
Copy link

We have this exact problem

@applefanbois
Copy link

The problem is still there in
Microsoft.WindowsAppSDK 1.2.221209.1

@gabbybilka gabbybilka added bug Something isn't working area-WebView area-Input labels Jan 5, 2023
@Eilon
Copy link
Member

Eilon commented Jan 5, 2023

To repro this in a trivial WinUI3 app:

  1. Create a new C# WinUI3 project in VS
  2. Change MainWindow.xaml to have just a WebView2:
    <WebView2 x:Name="wv2" ></WebView2>
  3. Change MainWindow.xaml.cs to have this code:
        public MainWindow()
        {
            this.InitializeComponent();
    
            wv2.CoreWebView2Initialized += Wv2_CoreWebView2Initialized;
    
            wv2.EnsureCoreWebView2Async();
        }
    
        private void Wv2_CoreWebView2Initialized(WebView2 sender, CoreWebView2InitializedEventArgs args)
        {
            wv2.NavigateToString(@"
    <html>
    <body>
    <h1>Hello, world!</h1>
    
    <div class=""container"">
        <div class=""row"">
            <div class=""col"">
                <input class=""form-control"" type=""text"" />
            </div>
        </div>
        <div class=""row"">
            <div class=""col"">
                <input class=""form-control"" type=""text"" />
            </div>
        </div>
    </div>
    </body>
    </html>
    ");
        }
  4. Run the app and start typing in the two textboxes while using the mouse to click back and forth between them

Eventually you'll still be able to type, but clicking with the mouse won't work.

Can't really tell from the screenshot, but I can assure you that keyboard/typing works, yet I can't click on the textboxes (it ignores the clicks):

image

@baaaaif
Copy link

baaaaif commented Jan 9, 2023

we're affected too
--> upvote...

@applefanbois
Copy link

applefanbois commented Jan 9, 2023

Do they even test it more than 2 seconds before releasing it?

To be fair, crApple is not better, last year the macOS WKWebview was crashing all the times and it took 8 months before they fix it. This year Apple WKWebview on macOS Intel will never trigger the onKey events, so every website on the planet with a text input will not work.

It just proves that big corps don't test before releasing and not only the programmers suffers, but in the end their customers suffer from their lack of respect. Just 5 minutes of using their own tools would show them that it does not work at all.

@AdriaanLarcai
Copy link

We are also affected by this problem and our implementation of the Monaco editor. We cannot go live with this issue. Please resolve this ASAP.

@lgBlog
Copy link

lgBlog commented Feb 15, 2023

Is there any progress on the problem?

@Xyncgas
Copy link

Xyncgas commented Feb 15, 2023

This would've made bill gates poor back in the days

@applefanbois
Copy link

applefanbois commented Feb 15, 2023

Bill Gates best contribution to the world is not Windows (a cheap copy of CPM and YES windows is CPM not Unix based), but the BASIC rom chip (he was the one who programmed it) that was included in every C64, ZX Spectrum, Tandy COCO, and Atari 8bit computers. Bill was a true programmer, not some XML pretentious scripters. BASIC was the revolution that made the 80's kids and normies do stuff and become programmers.

@Xyncgas
Copy link

Xyncgas commented Feb 15, 2023

Bill was a true programmer

Sorry I didn't know better, thanks for the information given

@codendone
Copy link
Contributor

Tracking with internal bug.

@Xyncgas
Copy link

Xyncgas commented Feb 17, 2023

I suspect it's because they are using Task based mechanism to handle user input then send it to the browser like a proxy, and they use some kinds of mutex or lock that doesn't get released properly. If that's happening I would like to input directly to the browser without this extra layer and if we are using native control with webview then we cover the browser layer with the native layer but no proxy-ing (unless it's needed?)

@applefanbois
Copy link

applefanbois commented Feb 17, 2023

The design of the MS framework is baffling and insane. Everything is async so everything becomes 400x slower than anything on Android and Apple because of the useless context switching (only I should decide what is async). And the biggest sin of the computer world : MS are a huge fan of thread re-entrance where our code running on the main thread will be pause execution mid-way (by MS) and another main thread task from MS will trigger again the same code and complete and then the code that was running will resume.

Instead of putting the next task on the main thread queue, they pause our main. This is criminally insane and dangerous. Another problem is that every MS function can throw and it is never mentioned in the documentation. Worst most of the time you will get unhandled exception inside a try catch block.

Not only it is painful to me an my customers because it require 100x more work to make the app just not crash every 2 minutes, but everything made by MS will be unstable, including WebView2 that crash every seconds.

There are so many wait, dispatch and useless validation just so the app won't crash every second. Anytime you call a MS function, you risk crashing the app. But getting so many unhandled exception inside try catch block is maddening.

Stop throwing MS, just make your code work. There is even thread re-entrance inside the MS library. Found that if you call the HttpClient thousands of time over 1 hour, eventually, deep inside MS code, there will be thread-re-entrance where the same line of code is executed twice and that will crash the app.

Because it is never mentioned anywhere on the internet that anything you do can be interrupted by MS and then called multiple times while the other did not even complete. You have to be paranoid and add a if (isFinishedExecuting) everywhere absolutely everywhere at the beginning of every functions. And if you do log the name of every function, you will see that everything is out of order.

I draw the buttons myself with Win2D, everything is async and waiting. Because of that drawing a button on windows is 400x slower than on a Mac. The app on iOS and macOS is rendering at 4x the resolution (oversampling) and it runs at 60fps. On windows, I had to render 1:1 and disabled animation. Everything is stuttering on MS, nothing is smooth. My pc has a 2080ti and the apple product have cheap onboard gpu. Microsoft design has a cost in speed and in stability and we are the one paying for it.

@Xyncgas
Copy link

Xyncgas commented Feb 18, 2023

How come cloud gaming doesn't have this problem

@KieranDevvs
Copy link

Tracking with internal bug.

Internal tracking is great... but can the users please get an update?

@alelom
Copy link

alelom commented Feb 22, 2023

Just reporting another instance of this bug that is completely deal-breaking for my application developed in MAUI Hybrid.

@ctigrisht
Copy link

We can't develop our app and was forced to put the windows version of the MAUI blazor project on hold, forced to use it on android device only.

@Xyncgas
Copy link

Xyncgas commented Feb 28, 2023

We can't develop our app and was forced to put the windows version of the MAUI blazor project on hold, forced to use it on android device only.

.NET 6 still works
On another environment, copy your project and change it all from .NET 7 to .NET 6, then wait for the problem fixed.
You can update client on windows once it's fixed

@codendone codendone added the Status: Fixed internally The issue has been fixed but has not yet shipped in a release. label Feb 28, 2023
@ctigrisht
Copy link

You can update client on windows once it's fixed

It says "fixed internally", does that mean a public fix is coming soon? thanks?

@KieranDevvs
Copy link

We can't develop our app and was forced to put the windows version of the MAUI blazor project on hold, forced to use it on android device only.

.NET 6 still works On another environment, copy your project and change it all from .NET 7 to .NET 6, then wait for the problem fixed. You can update client on windows once it's fixed

Its not that easy, there are a lot of features and API's that were introduced in .NET 7 that people are using. It turns into a migration project.

@Xyncgas
Copy link

Xyncgas commented Mar 1, 2023

This bug actually seems very interesting, can you guys tell a story on how it was fixed, what went wrong was it hard

@applefanbois
Copy link

I bet that it was threading problem. Same code executing again while the previous one has not completed. They should use more TryEnqueue() and put the next job on the thread queue so it will be executed when the thread is free.

@KieranDevvs
Copy link

This bug actually seems very interesting, can you guys tell a story on how it was fixed, what went wrong was it hard

Lets just focus on actually getting the bug fix first.

@gabbybilka What's the point of having an open source community with issue tracking if you're just going to track it internally and never respond to the public?

@true-perfect-code
Copy link

Will the update be available to us when a new nuget version of Microsoft.Web.WebView2 is released here?

See https://www.nuget.org/packages/Microsoft.Web.WebView2

@Ewerton
Copy link

Ewerton commented Mar 9, 2023

By the way, is there a way of force my .Net Maui App to use a specific version of Microsoft.Web.WebView2?

@vallgrenerik
Copy link

@Eilon Do you know how we (.NET MAUI Blazor developers) will get this fix?
Is it by nuget, VS, new SDK? 😊
Thanks in advance and have a nice weekend!

@codendone
Copy link
Contributor

The fix will be delivered as a Windows App SDK update.

@vallgrenerik
Copy link

The fix will be delivered as a Windows App SDK update.

Hi!
I don't think I have installed any Windows sdk explicitly. I have just installed the Visual studio MAUI workload. Will I get it in a VS update then? 😊

@Xyncgas
Copy link

Xyncgas commented Mar 12, 2023

Hi! I don't think I have installed any Windows sdk explicitly. I have just installed the Visual studio MAUI workload. Will I get it in a VS update then? 😊

yes, Visual Studio is microsoft's powerful IDE for making all kinds of program. When you install a 'workload' you installed what you needed to develop for the application. A couple years / months ago there is Xamarin, their selling point was that you can write UI that run on Android + IOS, while still having access to native UI you are mostly writing 'common' UI features for both platform together. Xamarin achieved this by using native dependency for each platforms, MAUI too is using WindowsSDK when your app is going to be running on WIndows. When you are updating Visual Studio you are getting the newest version of the SDK for your development.

Meanwhile, these SDK can still be installed via nuget packages sometimes. People who doesn't use Visual Studio does a lot stuffs manually.

For example, in order to write C++ to compile to webassembly, you first have to find tools like emscripten, which turns out providing you with other tools to compile your programing languages to IL using LLVM and then compiles IL to webassembly. It's people's decision for how to do certain things and they provide the way to do it for you, you don't have to worry about it mostly because it works, just like when you are coding for Blazor.Webassembly .NET compiles your code to webassembly using emscripten too

@true-perfect-code
Copy link

If I understand you correctly @Xyncgas , we don't have to look for new Nuget versions or donwload SDK (see https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads), we just wait for the next Visual Studio update.

I need to get another thing off at this point. The fact that this problem has dragged on for so long indicates that MAUI is used almost exclusively with XAML. And if someone then wants to display the web content in their app, then they will have the current problem through WebView2. And from the way it seems, it's really only a few programmers.
On the other hand, if you use MAUI with Blazor, then there is no workaround and with such errors in the VebView component, the developed app is unusable because Blazor cannot work with MAUI without WebView. Two points worry me a lot here:

  1. the heavy dependency on WebView from MAUI Blazer or no alternative.
  2. the fact that few people realise the benefits of MAUI Blazor. Here I am thinking especially of XAML vs. HTML/CSS. I have been programming with WPF for more than 10 years and I used to work on one or another web project in between. I was very happy a few years ago when Blazor came out, because it has a lot of advantages compared to XAML. Unfortunately, I have the impression that most programmers don't see it that way. Why is that?

Thanks

@Xyncgas
Copy link

Xyncgas commented Mar 13, 2023

I don't like XAML, it's a static description, where as html you can change it dynamically and add event listeners to elements.
The overhead of parsing plaintext html might seem stupid, it is actually very fast to parse string due to SIMD optimizations.

Everyone seriously wanting a MAUI.Blazor app can switch back to .NET 6 and this problem will not exist, publishers can choose the publish a webview that's evergreen or with the version locked.

the heavy dependency on WebView from MAUI Blazer or no alternative.

The dependency for MAUI.Blazor to have webview is so there is a browser to render web content, although it would be nice if we can draw ui using a unified rendering engine like a browser but without a browser and directly use the underlying available GUI framework for that platform

@gabbybilka gabbybilka added this to the 1.3 milestone Mar 14, 2023
@koenvd
Copy link

koenvd commented Mar 15, 2023

Tried to get some feedback in the WinUI community call but had no luck @gabbybilka (I noticed as well the 1.3 milestone was added). But any update when a fix would become available? cc @codendone

@gabbybilka
Copy link
Member

Fixed and available in 1.2.5: https://www.nuget.org/packages/Microsoft.WindowsAppSDK/1.2.230313.1 Will be available in 1.3.0 when it ships as well.

@AdriaanLarcai
Copy link

Fixed and available in 1.2.5: https://www.nuget.org/packages/Microsoft.WindowsAppSDK/1.2.230313.1 Will be available in 1.3.0 when it ships as well.

Thank you!

@koenvd
Copy link

koenvd commented Mar 15, 2023

Awesome! Thanks!!

@KieranDevvs
Copy link

@Eilon can we get Microsoft.WindowsAppSDK upgraded to this version (1.2.230313.1) on MAUI?

@DierkDroth
Copy link

Alright! At first glance a long standing issue which as road block for me is resolved now MicrosoftEdge/WebView2Feedback#3167

Fingers crossed!

@ManbirSinghRakhra
Copy link

ManbirSinghRakhra commented Mar 17, 2023

How do we update it in MAUI? I have seen the nuget package manager is saying this package is blocked by the project.
I have tried to add it in the csproj manually.

Do we need to do any thing special for updating it inside Maui Blazor App?

@rusfield
Copy link

rusfield commented Mar 17, 2023

How do we update it in MAUI? I have seen the nuget package manager is saying this package is blocked by the project. I have tried to add it in the csproj manually.

Do we need to do any thing special for updating it inside Maui Blazor App?

In my MAUI Blazor csproj, I have added this package reference manually into an ItemGroup tag (where all my other package references are), and it seems to have done it for me (at least no freezes so far):
<ItemGroup> <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230313.1" /> </ItemGroup>

I was also struggling with this "blocked by project" thing and could not do it through the package manager.
I think you can verify whether the new version gets installed by expanding your Blazor MAUI project > Dependencies > Packages > Microsoft.WindowsAppSDK (version), in Visual Studio after rebuilding, to verify that its updated.

@Xyncgas
Copy link

Xyncgas commented Mar 30, 2023

When can we get patched

@true-perfect-code
Copy link

I have updated my Visual Studio to version 17.5.3 and the error is fixed on Windows 10.

Unfortunately, it did not work on Windows Server 2019. I have written a new post about this here (but no feedback from WebView2 team yet). See MicrosoftEdge/WebView2Feedback#3333

@lvendramini
Copy link

Fixed and available in 1.2.5: https://www.nuget.org/packages/Microsoft.WindowsAppSDK/1.2.230313.1 Will be available in 1.3.0 when it ships as well.

We tried this but the maui window could not be closed in the header X or maximize the window.

@Xyncgas
Copy link

Xyncgas commented Apr 6, 2023

If I create a new MAUI.Blazor project, does this problem still exist

@lvendramini
Copy link

If I create a new MAUI.Blazor project, does this problem still exist
yes

@Eilon
Copy link
Member

Eilon commented Apr 6, 2023

See this comment for how to get the fix in a .NET MAUI Blazor project: MicrosoftEdge/WebView2Feedback#3003 (comment)

@Xyncgas
Copy link

Xyncgas commented May 14, 2023

is this included inside 1.3.230502000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Input area-WebView bug Something isn't working Status: Fixed internally The issue has been fixed but has not yet shipped in a release.
Projects
None yet
Development

No branches or pull requests