How to allow browsers in sandbox to restore their windows on the correct virtual desktop? #1326
Replies: 3 comments 3 replies
-
I have investigated this issue and it seams not be easy to fix, you need to open the right IPC paths, some dynamic one I can't pinpoint how to do exactly instead of just opening everything. It might be possible to proxy the request over the service but that would require recreating a dummy IVirtualDesktopManager interface to intercept the calls |
Beta Was this translation helpful? Give feedback.
-
Ok there is an easy fix after all, but I'm not sure about the implications, |
Beta Was this translation helpful? Give feedback.
-
This is the reason why I use my main browser outside of the sandbox. |
Beta Was this translation helpful? Give feedback.
-
Web browsers allow users to restore their previously closed browser windows or even the whole session.
What's interesting about some browsers (especially chromium-based ones) is that they can remember what virtual desktop each of their browser windows is on. So when you restore a browser window, that window will be opened on the virtual desktop it was opened on before, as long as that virtual desktop still exists.
However, if you open the browser inside a sandbox, the browser will lose the ability to put the restored windows onto their corresponding virtual desktops. All the windows will be left on the current desktop.
So the question is, is there something I can do to allow browsers in a sandbox to restore their windows on the correct virtual desktop?
I did some research about that, but without much success.
As far as I know, the only documented API that allows programs to interact with Windows' virtual desktop feature is the IVirtualDesktopManager COM interface. The ability it provides for the programs is just the bare minimum, though.
It only has 3 methods.
So I wrote a simple program to test it. It can open a window, save the ID of the virtual desktop the window is on, or move the window to the desktop whose ID has been saved.
Outside the sandbox it worked just fine. But when I ran it inside a sandbox with the default settings, it was able to initialize COM environment and create an instance of
IVirtualDesktopManager
, but showed me an error when trying to get the desktop ID, saying "Class not registered".Then I enabled the trace log, performed that operation again, and got a
ComClass(U) {228826AF-02E1-4226-A9E0-99A855E455A6} ?
line in my log. I added this GUID in the OpenClsid setting, and relaunched the program. It still failed to obtain the desktop ID, but showed me a different error message: "Operation aborted".My system is Windows 10 Home 21H1 64-bit by the way. And the program I wrote is just a C++ program that does nothing except creating windows and invoking
IVirtualDesktopManager::GetWindowDesktopId
andIVirtualDesktopManager::MoveWindowToDesktop
.For those who are interested, here's my code. A single file C++ program.
VirtualDesktopTest Program Code.cpp
Here's something that may be off topic.
Seems that the sandbox can isolate programs from some Windows system features. The virtual desktop feature mentioned here is one of them. Also, for example, Microsoft Edge will show the media file playing in web pages in SystemMediaTransportControls, i.e. the system media control popup next to the volume popup, but sandboxed Microsoft Edge won't.
Windows has a feature that can display your Microsoft Edge tabs as items in the task switcher, i.e. the Alt-Tab view. As I often have hundreds of tabs and several browser windows open (and yes, I am using Microsoft Edge as my main browser), I turned off the feature in the system settings. However, it seems that this feature cannot be turned off completely, and it's causing bugs like getting your tabs displayed as a window of File Explorer, and displaying lots of stacked minimized ghost tab windows when you switch between virtual desktops, which I'm suffering a lot because I often use Microsoft Edge and the virtual desktop feature.
The worst bug for me though, is that if you have too many Microsoft Edge tabs open, like, a few hundred tabs or over 1,000 tabs, Explorer will be slowed down and will become unstable. (Well you can actually open that many tabs with just 16 GB of memory because the browser will automatically - or you can manually - discard tabs)
When you are having that many Microsoft Edge tabs open, restarting Explorer will take you half a minute. And opening Task View can take several seconds. If you decide to move a Microsoft Edge window full of tabs to another virtual desktop, you may have to wait for a minute - literally.
However, if I run Microsoft Edge in a sandbox, then that bug will disappear. Explorer and the Task View will still be as fast even though I'm having the same amount of Microsoft Edge tabs open. That may be because the isolation from a certain system component prevents Microsoft Edge from telling the system about the open tabs, and the system won't spend lots of CPU resources to process the data each time I open the Task View.
The drawback though, is that the sandbox also prevents Microsoft Edge from putting their windows on the correct virtual desktop.
Beta Was this translation helpful? Give feedback.
All reactions