Skip to content

Commit

Permalink
Fabric: Assert on destruction non-empty of ShadowTreeRegistry
Browse files Browse the repository at this point in the history
Summary:
Destruction of Scheduler (and ShadowTreeRegistry as part of it) which has some running Surfaces is not a good thing and practically a bug on the application layer.
With this assert we throw early to flag the issue.

Changelog: [Internal] - Dev only assert indicating a broken invariant in ShadowTreeRegistry

Reviewed By: sammy-SC

Differential Revision: D17924491

fbshipit-source-id: 6b7433fe47630e993e7d5b969f3113f96124b6c9
  • Loading branch information
shergin authored and facebook-github-bot committed Oct 15, 2019
1 parent e7ef992 commit 8bce9c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ReactCommon/fabric/mounting/ShadowTreeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
namespace facebook {
namespace react {

ShadowTreeRegistry::~ShadowTreeRegistry() {
assert(registry_.size() == 0 && "Deallocation of non-empty `ShadowTreeRegistry`.");
}

void ShadowTreeRegistry::add(std::unique_ptr<ShadowTree> &&shadowTree) const {
std::unique_lock<better::shared_mutex> lock(mutex_);

Expand Down
1 change: 1 addition & 0 deletions ReactCommon/fabric/mounting/ShadowTreeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace react {
class ShadowTreeRegistry final {
public:
ShadowTreeRegistry() = default;
~ShadowTreeRegistry();

/*
* Adds a `ShadowTree` instance to the registry.
Expand Down

0 comments on commit 8bce9c5

Please sign in to comment.