Fix KERN_INVALID_ADDRESS in configureNextLayoutAnimation
Summary: Changelog: [Internal] The crash is caused by dereferencing invalid pointer. This can happen because `UIManager` can outlive `RCTScheduler` and `Scheduler`. Here we make sure when `Scheduler` is being deconstructed, UIManager's pointer is invalidated. I don't think this is ideal solution but it should fix the crash. Ideally we want the owner of animation delegate to invalidate the pointer. Reviewed By: JoshuaGross Differential Revision: D21922910 fbshipit-source-id: b2a56c1104574cecebaffad1bcbcbff82c1fa0cf
This commit is contained in:
Родитель
001eb7cbd6
Коммит
6860cb0775
|
@ -127,6 +127,7 @@ Scheduler::~Scheduler() {
|
||||||
|
|
||||||
// The thread-safety of this operation is guaranteed by this requirement.
|
// The thread-safety of this operation is guaranteed by this requirement.
|
||||||
uiManager_->setDelegate(nullptr);
|
uiManager_->setDelegate(nullptr);
|
||||||
|
uiManager_->setAnimationDelegate(nullptr);
|
||||||
|
|
||||||
// Then, let's verify that the requirement was satisfied.
|
// Then, let's verify that the requirement was satisfied.
|
||||||
auto surfaceIds = std::vector<SurfaceId>{};
|
auto surfaceIds = std::vector<SurfaceId>{};
|
||||||
|
|
|
@ -318,8 +318,7 @@ void UIManager::shadowTreeDidFinishTransaction(
|
||||||
|
|
||||||
#pragma mark - UIManagerAnimationDelegate
|
#pragma mark - UIManagerAnimationDelegate
|
||||||
|
|
||||||
void UIManager::setAnimationDelegate(
|
void UIManager::setAnimationDelegate(UIManagerAnimationDelegate *delegate) {
|
||||||
UIManagerAnimationDelegate *delegate) const {
|
|
||||||
animationDelegate_ = delegate;
|
animationDelegate_ = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class UIManager final : public ShadowTreeDelegate {
|
||||||
* The delegate is stored as a raw pointer, so the owner must null
|
* The delegate is stored as a raw pointer, so the owner must null
|
||||||
* the pointer before being destroyed.
|
* the pointer before being destroyed.
|
||||||
*/
|
*/
|
||||||
void setAnimationDelegate(UIManagerAnimationDelegate *delegate) const;
|
void setAnimationDelegate(UIManagerAnimationDelegate *delegate);
|
||||||
|
|
||||||
void animationTick();
|
void animationTick();
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class UIManager final : public ShadowTreeDelegate {
|
||||||
|
|
||||||
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
||||||
UIManagerDelegate *delegate_;
|
UIManagerDelegate *delegate_;
|
||||||
mutable UIManagerAnimationDelegate *animationDelegate_{nullptr};
|
UIManagerAnimationDelegate *animationDelegate_{nullptr};
|
||||||
UIManagerBinding *uiManagerBinding_;
|
UIManagerBinding *uiManagerBinding_;
|
||||||
ShadowTreeRegistry shadowTreeRegistry_{};
|
ShadowTreeRegistry shadowTreeRegistry_{};
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче