MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[.Net] ExecuteScriptAsync / PostWebMessageAsJson / PostWebMessageAsString with buffer - not string

Open
#2,193 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.

With a certain frequency (~ 2 seconds), we need to execute some rather large scripts in WebView2. Because ExecuteScriptAsync only takes a string as a parameter, and the string in .Net is an immutable type, then we can't use a buffer for this. As a result every time we need to create a new one, and most of the time the garbage collector collects these strings, which naturally leads to lags (not visual of course, but significant for us) :(

Describe the solution you'd like and alternatives you've considered.

Create an overload of ExecuteScriptAsync / PostWebMessageAsJson / PostWebMessageAsString that will take some buffer as input parameter (ReadOnlyMemory<char> / char[]). For example:

public System.Threading.Tasks.Task<string> ExecuteScriptAsync (ReadOnlyMemory<char> script);

May be some other workaround exists that I missed?

AB#38225871

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the requested overloads for ExecuteScriptAsync, PostWebMessageAsJson, and PostWebMessageAsString, along with the proposed ReadOnlyMemory or char[] inputs. Then locate the corresponding .NET WebView2 API definitions and assess the buffer-lifetime and interop requirements. Done means the API change is specified and implemented consistently for all three methods, with validation for large, recurring calls.

Written by the indexing model from the issue text.

Assessment

Domain
api, desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.