mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
Avoid online loading hang on stalled terrain streaming
This commit is contained in:
parent
fdc614902b
commit
db4a40a4e6
1 changed files with 15 additions and 1 deletions
|
|
@ -1982,9 +1982,12 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
||||||
terrainMgr->update(*camera, 1.0f);
|
terrainMgr->update(*camera, 1.0f);
|
||||||
|
|
||||||
auto startTime = std::chrono::high_resolution_clock::now();
|
auto startTime = std::chrono::high_resolution_clock::now();
|
||||||
const float maxWaitSeconds = 30.0f;
|
auto lastProgressTime = startTime;
|
||||||
|
const float maxWaitSeconds = 20.0f;
|
||||||
|
const float stallSeconds = 5.0f;
|
||||||
int initialRemaining = terrainMgr->getRemainingTileCount();
|
int initialRemaining = terrainMgr->getRemainingTileCount();
|
||||||
if (initialRemaining < 1) initialRemaining = 1;
|
if (initialRemaining < 1) initialRemaining = 1;
|
||||||
|
int lastRemaining = initialRemaining;
|
||||||
|
|
||||||
// Wait until all pending + ready-queue tiles are finalized
|
// Wait until all pending + ready-queue tiles are finalized
|
||||||
while (terrainMgr->getRemainingTileCount() > 0) {
|
while (terrainMgr->getRemainingTileCount() > 0) {
|
||||||
|
|
@ -2024,6 +2027,11 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
||||||
loadingScreen.setProgress(progress);
|
loadingScreen.setProgress(progress);
|
||||||
loadingScreen.render();
|
loadingScreen.render();
|
||||||
window->swapBuffers();
|
window->swapBuffers();
|
||||||
|
|
||||||
|
if (remaining != lastRemaining) {
|
||||||
|
lastRemaining = remaining;
|
||||||
|
lastProgressTime = std::chrono::high_resolution_clock::now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto elapsed = std::chrono::high_resolution_clock::now() - startTime;
|
auto elapsed = std::chrono::high_resolution_clock::now() - startTime;
|
||||||
|
|
@ -2031,6 +2039,12 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
||||||
LOG_WARNING("Online terrain streaming timeout after ", maxWaitSeconds, "s");
|
LOG_WARNING("Online terrain streaming timeout after ", maxWaitSeconds, "s");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
auto stalledFor = std::chrono::high_resolution_clock::now() - lastProgressTime;
|
||||||
|
if (std::chrono::duration<float>(stalledFor).count() > stallSeconds) {
|
||||||
|
LOG_WARNING("Online terrain streaming stalled for ", stallSeconds,
|
||||||
|
"s (remaining=", lastRemaining, "), continuing without full preload");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Delay(16);
|
SDL_Delay(16);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue