fix: make render orchestrator teardown safe
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
tei
2026-10-07 08:41:08 +09:00
parent d29e84c1a9
commit 64cf8f4435
13 changed files with 1483 additions and 6 deletions

View File

@@ -191,9 +191,21 @@ RenderOrchestrator::~RenderOrchestrator() {
}
}
// Wait for any deferred cleanup tasks to complete before releasing and potentially
// destroying the scheduler. Those cleanup tasks must not hold the final reference
// to the scheduler because it cannot be destroyed from one of its own pool threads.
// Finish work that can still reach the source observers before detaching them.
threadPool.waitForEmpty();
for (auto& entry : renderSources) {
entry.second->setObserver(nullptr);
}
glyphManager->setObserver(nullptr);
imageManager->setObserver(nullptr);
// Tile destructors can synchronously report Cancelled and enqueue further work.
// Destroy sources while the readiness state and its mutex are still alive.
renderSources.clear();
// Drain work submitted by source/tile destruction before the scheduler and
// the remaining orchestrator state are torn down.
threadPool.waitForEmpty();
}

View File

@@ -311,6 +311,9 @@ public:
const ZoomHistory& getZoomHistory() const { return zoomHistory; }
private:
// Allows the focused teardown test to install a pending tile-backed source.
friend struct RenderOrchestratorTeardownTestAccess;
bool isLoaded() const;
bool hasTransitions(TimePoint) const;

View File

@@ -71,7 +71,7 @@ RenderSource::RenderSource(Immutable<style::Source::Impl> impl)
RenderSource::~RenderSource() = default;
void RenderSource::setObserver(RenderSourceObserver* observer_) {
observer = observer_;
observer = observer_ ? observer_ : &nullObserver;
}
void RenderSource::onTileChanged(Tile& tile) {