mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Handle double SurfaceHandler#stop call (#37716)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37716 We call `surfaceHandler.stop` both from `SurfaceHandlerBinding` as well as `Binding`. Since we don't check asserts in production, the second one should generally be a no-op, but may be causing a crash due to incorrectly de-referencing a unique_ptr. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D46441620 fbshipit-source-id: e93b9722fd717947ebf772f545f692c2e31f816e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3221f37ea1
commit
6a710670f0
@@ -108,7 +108,9 @@ void SurfaceHandler::stop() const noexcept {
|
||||
// mounted views, so we need to commit an empty tree to trigger all
|
||||
// side-effects (including destroying and removing mounted views).
|
||||
react_native_assert(shadowTree && "`shadowTree` must not be null.");
|
||||
shadowTree->commitEmptyTree();
|
||||
if (shadowTree) {
|
||||
shadowTree->commitEmptyTree();
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceHandler::setDisplayMode(DisplayMode displayMode) const noexcept {
|
||||
|
||||
@@ -231,19 +231,19 @@ ShadowTree::Unique UIManager::stopSurface(SurfaceId surfaceId) const {
|
||||
// Waiting for all concurrent commits to be finished and unregistering the
|
||||
// `ShadowTree`.
|
||||
auto shadowTree = getShadowTreeRegistry().remove(surfaceId);
|
||||
if (shadowTree) {
|
||||
// We execute JavaScript/React part of the process at the very end to
|
||||
// minimize any visible side-effects of stopping the Surface. Any possible
|
||||
// commits from the JavaScript side will not be able to reference a
|
||||
// `ShadowTree` and will fail silently.
|
||||
runtimeExecutor_([=](jsi::Runtime &runtime) {
|
||||
SurfaceRegistryBinding::stopSurface(runtime, surfaceId);
|
||||
});
|
||||
|
||||
// We execute JavaScript/React part of the process at the very end to minimize
|
||||
// any visible side-effects of stopping the Surface. Any possible commits from
|
||||
// the JavaScript side will not be able to reference a `ShadowTree` and will
|
||||
// fail silently.
|
||||
runtimeExecutor_([=](jsi::Runtime &runtime) {
|
||||
SurfaceRegistryBinding::stopSurface(runtime, surfaceId);
|
||||
});
|
||||
|
||||
if (leakChecker_) {
|
||||
leakChecker_->stopSurface(surfaceId);
|
||||
if (leakChecker_) {
|
||||
leakChecker_->stopSurface(surfaceId);
|
||||
}
|
||||
}
|
||||
|
||||
return shadowTree;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user