Fix crash caused by stale ViewTreeObserver