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

Writing to CoreWebView2SharedBuffer times out #3108

Closed
david-risney opened this issue Jan 6, 2023 · 5 comments
Closed

Writing to CoreWebView2SharedBuffer times out #3108

david-risney opened this issue Jan 6, 2023 · 5 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@david-risney
Copy link
Contributor

david-risney commented Jan 6, 2023

Originally posted by @Take-A-Byte in #5 (comment)
Moving to its own new issue.

Also, Are these usable in C# - UWP? Because with the following code, it is not able to close the writer stream

           var baseStr = "Checking if small stream works";
            using (var strstream = GenerateStreamFromString(baseStr))
            {
                var environment = await CoreWebView2Environment.CreateAsync();
                using (CoreWebView2SharedBuffer sharedBuffer = environment.CreateSharedBuffer((ulong)strstream.Length))
                {
                    using (var stream = sharedBuffer.OpenStream())
                    {
                        using (StreamWriter writer = new StreamWriter(stream.AsStreamForWrite()))
                        {
                            writer.Write(strstream);
                        }
                    }
                }
            }

It times out. Here is the exact error message that I get on the screen -

image

(Text extracted from image)
Exception User-Unhandled
System.lO.lOException: 'The message filter indicated that the application is busy.
A COM call (IID: method index: 5) to an ASTA (thread
18420) appears deadlocked and was timed out'
Inner Exception
Exception: The message filter indicated that the application is busy
A COM call (IID {0000000C-0000-0000-C000-000000000046}, method index: 5) to an ASTA (thread
18420) appears deadlocked and was timed out.

AB#42876135

@LiangTheDev
Copy link
Member

@Take-A-Byte, while we investigate it, could you try to use alternative ways to work around the issue by using the following code instead of StreamWriter(stream.AsStreamForWrite())?

using (var writer = new Windows.Storage.Streams.DataWriter(stream))
{
  writer.WriteString(baseStr);
  await writer.StoreAsync();
}

@Take-A-Byte
Copy link

Take-A-Byte commented Jan 9, 2023

@LiangTheDev I tried this out and it works fine. Thanks for the suggestion 🙇

I am trying to find what is the difference between StreamWriter and DataWriter and what are guidelines on which to use when but I could not find anything in Microsoft docs so far. If you know any place I can look for the answer or if you could shed some light on this topic, I would love to know about it :)

@LiangTheDev
Copy link
Member

These is due to some subtlety in the WinRT to .NET stream adapter object returned from AsStreamForWrite(). DataWriter is a native Windows WinRT API that works better with other WinRT APIs. Developers should not be concerned with these and therefore it is not documented.
We will modify WebView2 runtime so that the code using StreamWriter also works.

@Take-A-Byte
Copy link

@LiangTheDev Thanks for the explanation. 🙇

@champnic
Copy link
Member

champnic commented Mar 6, 2023

Fixed in runtimes 111.0.1615.0+. Thanks!

@champnic champnic closed this as completed Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

4 participants