UI: Add timer to NewYouTubeAppDock()

CEF apparently doesn't like it and is unable to handle when you
destroy/recreate CEF instances very quickly, so... let's just put a
timer on this insanely terrible function. I guess. Whatever.
This commit is contained in:
Lain
2023-08-18 11:26:55 -07:00
parent 677c557243
commit a44ab2efcc
2 changed files with 15 additions and 0 deletions

View File

@@ -8484,11 +8484,25 @@ YouTubeAppDock *OBSBasic::GetYouTubeAppDock()
return youtubeAppDock;
}
#ifndef SEC_TO_NSEC
#define SEC_TO_NSEC 1000000000
#endif
void OBSBasic::NewYouTubeAppDock()
{
if (!cef_js_avail)
return;
/* make sure that the youtube app dock can't be immediately recreated.
* dumb hack. blame chromium. or this particular dock. or both. if CEF
* creates/destroys/creates a widget too quickly it can lead to a
* crash. */
uint64_t ts = os_gettime_ns();
if ((ts - lastYouTubeAppDockCreationTime) < (5ULL * SEC_TO_NSEC))
return;
lastYouTubeAppDockCreationTime = ts;
if (youtubeAppDock)
RemoveDockWidget(youtubeAppDock->objectName());