MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
453 stars 55 forks source link

[Feature]: Set or Get the WebView2 Control thread priority. #4610

Open PCRacer opened 5 months ago

PCRacer commented 5 months ago

Describe the feature/enhancement you need

I would like to simply call a function or procedure to set or get the WebView2 control's thread priority in order to match the WIN32 app's thread priority.

Simply put, I would like to escalate or deescalate the thread priority of the WebView2's instance to match to that of the WIN32 app running on it.

The scenario/use case where you would use this feature

This will enable high performance or normal system apps to function at the PC's highest or lowest capability, either for power conservation or high speed calculations or data search/manipulation at maximum CPU speed available.

How important is this request to you?

Very Important, as there is no way in accessing the WebView2 control's handle in order to set its thread priority!

Suggested implementation

Operation:

WebView2.ThreadPriority.SetPriority = IDLE_PRIORITY_CLASS WebView2.ThreadPriority.SetPriority = NORMAL_PRIORITY_CLASS WebView2.ThreadPriority.SetPriority = HIGHEST_PRIORITY_CLASS . . . . etc.

Var WebViewPriority: Integer;

WebViewPriority = WebView2.ThreadPriority.GetPriority;

What does your app do? Is there a pending deadline for this request?

This will also be more advantageous for online gamers or high performance stock trading systems in order to reduce latency and increase operational application speed for maximum data search and/or manipulation or feedback of data from an online database.

This will also be most advantageous for low power systems to conserve energy when running on battery power. The battery power switch from AC will be detected by the app and accordingly lower the WebView2 control's thread priority in order to further reduce energy consumption and speed of operation.

AB#52578898

champnic commented 4 months ago

✅ Successfully linked to Azure Boards work item(s):

LiangTheDev commented 4 months ago

Added a tracking work item. We will triage it. There are multiple processes involved in WebView2, so it is more complicated than simply setting a priority on webview thread.

The current behavior is that we try to automatically boost related renderer process when the app is in foreground and the app could set the WebView2 to be invisible to lower its resource usage, or even suspend it if not running any web code at all.