Bug 1665453 - Poll for native events in between prefetching early dlls r=agashlin

In the initial patches for bug 1656526, mhowell noticed that for startups which
take a very long time, if the user interacts with the skeleton UI window, the OS
will flag us as not responsive, which could be a poorer user experience than
seeing nothing. Since our UI is designed to look non-interactive anyway, we
assume that a better experience would be to simply squash the not responsive
response from the OS by trivially processing native events. It's not perfect in,
say, the event that startup is hung for some reason, but it's arguably preferable
to our old model of startup being hung, which was just nothing being displayed at
all.

Differential Revision: https://phabricator.services.mozilla.com/D91005
This commit is contained in:
Doug Thayer 2020-09-24 23:51:42 +00:00
parent ee29d74a9e
commit c0eae2f201
3 changed files with 21 additions and 0 deletions

View File

@ -535,4 +535,11 @@ MFBT_API void SetPreXULSkeletonUIEnabled(bool value) {
sPreXULSkeletonUIEnabled = true;
}
MFBT_API void PollPreXULSkeletonUIEvents() {
if (sPreXULSkeletonUIEnabled && sPreXULSkeletonUIWindow) {
MSG outMsg = {};
PeekMessageW(&outMsg, sPreXULSkeletonUIWindow, 0, 0, 0);
}
}
} // namespace mozilla

View File

@ -19,6 +19,7 @@ MFBT_API void PersistPreXULSkeletonUIValues(int screenX, int screenY, int width,
double cssToDevPixelScaling);
MFBT_API bool GetPreXULSkeletonUIEnabled();
MFBT_API void SetPreXULSkeletonUIEnabled(bool value);
MFBT_API void PollPreXULSkeletonUIEvents();
} // namespace mozilla

View File

@ -33,6 +33,7 @@ typedef void (*NSFuncPtr)();
# include <windows.h>
# include <mbstring.h>
# include "mozilla/WindowsVersion.h"
# include "mozilla/PreXULSkeletonUI.h"
typedef HINSTANCE LibHandleType;
@ -310,6 +311,18 @@ static nsresult XPCOMGlueLoad(const char* aXPCOMFile,
XPCOMGlueUnload();
return NS_ERROR_FAILURE;
}
# ifdef XP_WIN
// We call PollPreXULSkeletonUIEvents here in order to not get flagged by
// Windows as nonresponsive. In order to not be flagged as such, we seem to
// simply need to respond to *a* message every few seconds. The halfway
// point on slow systems between process start and nsWindow taking over the
// skeleton UI window seems to be XUL being loaded. Accordingly, placing
// this call here covers the most ground (as we will call this after
// prefetching and loading all of the dlls in dependentlibs.list, which
// includes xul.dll.)
PollPreXULSkeletonUIEvents();
# endif
}
#endif
return NS_OK;