Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore checking shadow tree commit cancellation after commit hook execution #38715

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ CommitStatus ShadowTree::tryCommit(
newRootShadowNode = delegate_.shadowTreeWillCommit(
*this, oldRootShadowNode, newRootShadowNode);

if (!newRootShadowNode ||
(commitOptions.shouldYield && commitOptions.shouldYield())) {
return CommitStatus::Cancelled;
}

// Layout nodes.
std::vector<LayoutableShadowNode const *> affectedLayoutableNodes{};
affectedLayoutableNodes.reserve(1024);
Expand All @@ -374,11 +379,6 @@ CommitStatus ShadowTree::tryCommit(

auto newRevisionNumber = oldRevision.number + 1;

if (!newRootShadowNode ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to remove the !newRootShadowNode check from here because we already checked it in the new block you added, but I think we should keep the rest. Layout is relatively slow so it could happen that the commit is requested to yield during layout, and we should still be able to cancel then. Changing this behavior without testing its impact would be risky.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing.

By the way, what do you think about restoring that block with moving it just after getting a lock and before checking for revision numbers' mismatch? It may allow developers to cancel commit instead of getting failure on specific cases and shouldn't cause any behaviour changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed suggested changes, @rubennorte give me a shout about your opinion on that approach

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that makes sense! thanks!

(commitOptions.shouldYield && commitOptions.shouldYield())) {
return CommitStatus::Cancelled;
}

{
std::lock_guard<std::mutex> dispatchLock(EventEmitter::DispatchMutex());

Expand Down