MicrosoftEdge / MicrosoftEdge/WebView2Feedback

WebView2 WPF application could not be loaded on second desktop created programmatically. ( Both on standard and Admin privilege's)

Open
#343 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

I want to load WPF WebView2 browser in new desktop created programmatically.
Later, I have reproduced the issue with WebView2 WPF sample application(WebView2WpfBrowser).
Application is started, but WebView2 control not loaded. Exception captured seems 0x80070578

Install-Package Microsoft.Web.WebView2 -Version 0.9.538
Could you check this issue..?
-------------------------- Source Code -------------------------------

#include
#include <processthreadsapi.h>
#include <Windows.h>
#include <winuser.h>
void CreateChildProcess();
int main()
{
std::cout << "Hello World!\n";
DWORD dwThreadId=::GetCurrentThreadId();
HDESK hOriginalDesk=::GetThreadDesktop(dwThreadId);
if (0==hOriginalDesk)
{
return false;
}

HDESK hUserDesktop = ::CreateDesktopA( "DesktopB",
	0,
	0,
	DF_ALLOWOTHERACCOUNTHOOK,
	GENERIC_ALL,
	0);

if (0==hUserDesktop )
{
	return false;
}


Sleep(5000);
if (!::SwitchDesktop(hUserDesktop))
{
	Sleep(30000);
	::SwitchDesktop(hOriginalDesk);
	return false;
}
CreateChildProcess();
Sleep(30000);
::SwitchDesktop(hOriginalDesk);

}

void CreateChildProcess( )
// Create a child process that uses the previously created pipes for STDIN and STDOUT.
{
CHAR szCmdline[] = "D:\WebView2\bin\Release\WebView2WpfBrowser.exe";

PROCESS_INFORMATION piProcInfo;
STARTUPINFOA siStartInfo;
BOOL bSuccess = FALSE;

// Set up members of the PROCESS_INFORMATION structure. 

ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));

// Set up members of the STARTUPINFO structure. 
// This structure specifies the STDIN and STDOUT handles for redirection.

ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.lpDesktop = (char*)"DesktopB";

// Create the child process. 

bSuccess = CreateProcessA(NULL,
	szCmdline,     // command line 
	NULL,          // process security attributes 
	NULL,          // primary thread security attributes 
	TRUE,          // handles are inherited 
	0,             // creation flags 
	NULL,          // use parent's environment 
	NULL,          // use parent's current directory 
	&siStartInfo,  // STARTUPINFO pointer 
	&piProcInfo);  // receives PROCESS_INFORMATION 

 // If an error occurs, exit the application. 
if (!bSuccess)
{
}
else
{
	// Close handles to the child process and its primary thread.
	// Some applications might keep these handles to monitor the status
	// of the child process, for example. 

	CloseHandle(piProcInfo.hProcess);
	CloseHandle(piProcInfo.hThread);

	// Close handles to the stdin and stdout pipes no longer needed by the child process.
	// If they are not explicitly closed, there is no way to recognize that the child process has ended.

}

}

// Please change szCmdline with exact path of WPF application.

AB#27803622

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 with the supplied CreateDesktopA and CreateProcessA reproduction and the WebView2WpfBrowser sample, using the second desktop setup and exception 0x80070578 as the initial checkpoints. Confirm whether the WebView2 control consistently fails to load there, then document a confirmed resolution or limitation for this scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.