Track detail: await history.go popstates before re-render after gap-fill revert/save

reopenDetail fired history.go(-count) then re-rendered synchronously, so the
async map/chart build raced the popstate unwind: the pending popstates
desynced the back stack and bumped the detail render token, and the render
bailed at the token check - map and charts came up blank until the next
event repainted them. Make reopenDetail async and await the popstate(s)
before showSessionDetail, the same resolve-on-popstate pattern as closeThen
(no setTimeout/setInterval).
This commit is contained in:
4aiman 2026-09-29 16:03:52 +03:00
commit fd178ad97d
2 changed files with 32 additions and 2 deletions

View file

@ -96,3 +96,20 @@ reopen -> убрал достройку -> зум/таскание; буфер
Проверка: воспроизвести тот же сценарий, снять logcat - ожидаем, что `tile memory limits
exceeded` резко упадёт/исчезнет, джанк уйдёт; POI на малом зуме - мало маркеров.
Результат (build 480): пользователь - "всё ок".
## Баг: после "убрать достройку" пусто (карта+графики) до следующего действия
Симптом: revert достройки -> графики и карта пропадают, из экрана трека не выкидывает,
появляются только после следующего действия ("Отмена"). Стек окон + гонка.
Корень: `reopenDetail` (main.js:1176) стрелял `history.go(-count)` (асинхронные popstate) и
СРАЗУ синхронно `showSessionDetail`. showSessionDetail пушит свою history-запись, потом
отложенные popstate от go(-count) раскручивают уже ЕЁ и десинхронят стек; при fallthrough в
renderScreen второй showSessionDetail бампает `_sessionDetailRender`, и первый async-рендер
карты/графиков бросается на проверке токена (5411) -> пусто до следующего события. Ровно тот
же класс, что чинил `closeThen()` (комментарий там про это).
Фикс: `reopenDetail` сделан async и ДОЖИДАЕТСЯ popstate от history.go перед showSessionDetail -
через Promise + слушатель popstate (как `closeThen`), без setTimeout/setInterval.
Проверка: revert на устройстве, по [SD]-логам один прогон showSessionDetail, карта+графики
сразу на месте.