Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Remove children when updating a host node to an element with nil children #210

Merged

Conversation

AmaranthineCodices
Copy link
Contributor

Closes #209. In ea822f6 we introduced an optimization in RobloxRenderer that avoids calling into the reconciler to update children if the element's children are nil. This introduced #209, where when updating a tree with an element that has nil children (not an empty table), the existing children are not unmounted.

Checklist before submitting:

  • Added entry to CHANGELOG.md
  • Added/updated relevant tests
  • Added/updated documentation

This caused an issue when updating an element that had children - when
an element went from having children to having nil children, the
rendered objects would not be removed.
@coveralls
Copy link

coveralls commented May 23, 2019

Coverage Status

Coverage remained the same at 93.058% when pulling 97a77ea on AmaranthineCodices:fix-209-reconcile-to-nil-children into 2fb60ea on Roblox:master.

@LPGhatguy
Copy link
Contributor

This change looks good to me, but I want to wait for @ZoteTheMighty.

Can we pull benchmark numbers out for this change, too?

@ZoteTheMighty
Copy link
Contributor

This looks okay to me, but I have a couple comments to consider:

I did some quick benchmarking, and there's a somewhat consistent 20-25% slowdown on benchmarks for specifically mount and update operations. Note that mounting and updating big nested trees sees a much smaller effect. The performance effect is specifically on the leaves of these element trees.

That said, there are a couple things we might be able to do regain some of this performance and still fix the bug.

  1. I'm not sure the mount case is actually going to cause this bug. We may be able to revert that bit and still pass our new test.
  2. We might be able to do a more intelligent short circuit with the update case along the lines of if children ~= nil or oldProps[Roact.Children] ~= nil then. Might be worth experimenting with.

Copy link
Contributor

@ZoteTheMighty ZoteTheMighty left a comment

Choose a reason for hiding this comment

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

Requesting changes (according to the above suggestions)

@ZoteTheMighty ZoteTheMighty requested review from ZoteTheMighty and removed request for ZoteTheMighty May 30, 2019 16:39
@ZoteTheMighty ZoteTheMighty dismissed their stale review May 30, 2019 16:40

Addressed with changes made on branch

src/RobloxRenderer.lua Outdated Show resolved Hide resolved
Co-Authored-By: Lucien Greathouse <me@lpghatguy.com>
Copy link
Contributor Author

@AmaranthineCodices AmaranthineCodices left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@ZoteTheMighty ZoteTheMighty left a comment

Choose a reason for hiding this comment

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

LG...T...M...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating from having children to having nil children doesn't remove children
4 participants