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

feat: improve rendering performance by content-visibility #17907

Merged
merged 5 commits into from
Apr 29, 2021
Merged

feat: improve rendering performance by content-visibility #17907

merged 5 commits into from
Apr 29, 2021

Conversation

lqs469
Copy link
Contributor

@lqs469 lqs469 commented Apr 21, 2021

Add the CSS content-visibility: auto to fluent-card of web-component. This style will avoid some unnecessary rendering processes when the components are not in the viewport.
It will improve the performance of the page, like some feeds flow or multiple cards grid.

Pull request checklist

None

Description of changes

Add CSS content-visibility: auto to all elements of fluent-card.

Focus areas to test

It shouldn't influence any feature or display of components.

lqs469 added 2 commits April 22, 2021 01:10
Add the CSS `content-visibility` to fluent-card of web-component. This style will avoid some unnecessary rendering processes when the components are not in the viewport.
It will improve the performance of the page, like some feeds flow or multiple cards grid.
…ility

feat: improve rendering performance by `content-visibility`
@size-auditor
Copy link

size-auditor bot commented Apr 21, 2021

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 1f31b1263b6d562edb2c5178648f846246a7ba14 (build)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 21, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9b6eb8d:

Sandbox Source
Fluent UI Button Configuration
codesandbox-react-template Configuration
codesandbox-react-northstar-template Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Apr 21, 2021

Perf Analysis

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 896 883 5000
BaseButton mount 890 907 5000
Breadcrumb mount 44001 43617 5000
ButtonNext mount 523 548 5000
Checkbox mount 1607 1512 5000
CheckboxBase mount 1503 1286 5000
ChoiceGroup mount 4772 5037 5000
ComboBox mount 984 1006 1000
CommandBar mount 10216 10089 1000
ContextualMenu mount 6264 6140 1000
DefaultButton mount 1124 1230 5000
DetailsRow mount 3639 3660 5000
DetailsRowFast mount 3642 3818 5000
DetailsRowNoStyles mount 3740 3611 5000
Dialog mount 1445 1484 1000
DocumentCardTitle mount 139 146 1000
Dropdown mount 3206 3323 5000
FocusTrapZone mount 1774 1790 5000
FocusZone mount 1804 1784 5000
IconButton mount 1699 1747 5000
Label mount 333 337 5000
Layer mount 1762 1767 5000
Link mount 468 456 5000
MakeStyles mount 1809 1778 50000
MenuButton mount 1471 1454 5000
MessageBar mount 2016 2004 5000
Nav mount 3259 3306 1000
OverflowSet mount 1006 1059 5000
Panel mount 1433 1431 1000
Persona mount 824 823 1000
Pivot mount 1435 1419 1000
PrimaryButton mount 1318 1274 5000
Rating mount 7600 7550 5000
SearchBox mount 1313 1307 5000
Shimmer mount 2520 2477 5000
Slider mount 1933 1965 5000
SpinButton mount 4996 4999 5000
Spinner mount 407 419 5000
SplitButton mount 3157 3213 5000
Stack mount 514 486 5000
StackWithIntrinsicChildren mount 1558 1546 5000
StackWithTextChildren mount 4514 4478 5000
SwatchColorPicker mount 10175 10470 5000
Tabs mount 1393 1396 1000
TagPicker mount 2462 2420 5000
TeachingBubble mount 11753 11851 5000
Text mount 416 428 5000
TextField mount 1339 1341 5000
ThemeProvider mount 1165 1208 5000
ThemeProvider virtual-rerender 603 601 5000
ThemeProviderNext mount 9209 9252 5000
Toggle mount 788 801 5000
buttonNative mount 117 122 5000

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🦄 Avatar.Fluent 0.17 0.47 0.36:1 2000 339
🦄 Button.Fluent 0.11 0.2 0.55:1 5000 538
🔧 Checkbox.Fluent 0.63 0.34 1.85:1 1000 631
🎯 Dialog.Fluent 0.15 0.21 0.71:1 5000 739
🔧 Dropdown.Fluent 3.08 0.41 7.51:1 1000 3079
🔧 Icon.Fluent 0.12 0.06 2:1 5000 609
🦄 Image.Fluent 0.07 0.13 0.54:1 5000 371
🔧 Slider.Fluent 1.61 0.46 3.5:1 1000 1606
🔧 Text.Fluent 0.07 0.03 2.33:1 5000 363
🦄 Tooltip.Fluent 0.14 0.89 0.16:1 5000 705

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AttachmentMinimalPerf.default 174 161 1.08:1
RefMinimalPerf.default 269 251 1.07:1
LoaderMinimalPerf.default 727 694 1.05:1
PopupMinimalPerf.default 742 706 1.05:1
AlertMinimalPerf.default 282 271 1.04:1
AvatarMinimalPerf.default 209 201 1.04:1
CardMinimalPerf.default 577 553 1.04:1
ChatDuplicateMessagesPerf.default 305 294 1.04:1
ChatWithPopoverPerf.default 385 369 1.04:1
ItemLayoutMinimalPerf.default 1310 1263 1.04:1
Icon.Fluent 609 585 1.04:1
AccordionMinimalPerf.default 162 158 1.03:1
AnimationMinimalPerf.default 434 420 1.03:1
HeaderSlotsPerf.default 781 761 1.03:1
LayoutMinimalPerf.default 386 374 1.03:1
MenuButtonMinimalPerf.default 1581 1536 1.03:1
TableManyItemsPerf.default 1914 1865 1.03:1
FlexMinimalPerf.default 309 303 1.02:1
ListCommonPerf.default 634 623 1.02:1
ProviderMergeThemesPerf.default 1705 1675 1.02:1
SegmentMinimalPerf.default 369 362 1.02:1
VideoMinimalPerf.default 612 601 1.02:1
Checkbox.Fluent 631 621 1.02:1
Text.Fluent 363 357 1.02:1
AttachmentSlotsPerf.default 1167 1152 1.01:1
BoxMinimalPerf.default 360 358 1.01:1
ButtonMinimalPerf.default 179 178 1.01:1
CarouselMinimalPerf.default 473 469 1.01:1
DialogMinimalPerf.default 746 735 1.01:1
EmbedMinimalPerf.default 4203 4169 1.01:1
FormMinimalPerf.default 421 418 1.01:1
PortalMinimalPerf.default 177 175 1.01:1
SkeletonMinimalPerf.default 373 368 1.01:1
SplitButtonMinimalPerf.default 3742 3711 1.01:1
StatusMinimalPerf.default 693 683 1.01:1
TextAreaMinimalPerf.default 490 487 1.01:1
TooltipMinimalPerf.default 976 965 1.01:1
TreeWith60ListItems.default 191 190 1.01:1
Avatar.Fluent 339 336 1.01:1
Button.Fluent 538 531 1.01:1
Slider.Fluent 1606 1586 1.01:1
ButtonOverridesMissPerf.default 1694 1699 1:1
ButtonUseCssNestingPerf.default 1083 1078 1:1
CheckboxMinimalPerf.default 2771 2773 1:1
GridMinimalPerf.default 352 351 1:1
InputMinimalPerf.default 1272 1278 1:1
LabelMinimalPerf.default 403 403 1:1
RadioGroupMinimalPerf.default 439 438 1:1
ReactionMinimalPerf.default 394 393 1:1
SliderMinimalPerf.default 1613 1621 1:1
IconMinimalPerf.default 602 601 1:1
TextMinimalPerf.default 351 352 1:1
CustomToolbarPrototype.default 3826 3813 1:1
ToolbarMinimalPerf.default 931 935 1:1
Dialog.Fluent 739 736 1:1
Tooltip.Fluent 705 708 1:1
ButtonUseCssPerf.default 816 822 0.99:1
DropdownMinimalPerf.default 3116 3139 0.99:1
ListMinimalPerf.default 507 513 0.99:1
ListNestedPerf.default 569 577 0.99:1
TreeMinimalPerf.default 773 779 0.99:1
Dropdown.Fluent 3079 3112 0.99:1
ButtonSlotsPerf.default 552 565 0.98:1
DividerMinimalPerf.default 371 379 0.98:1
ImageMinimalPerf.default 385 393 0.98:1
MenuMinimalPerf.default 836 849 0.98:1
TableMinimalPerf.default 418 425 0.98:1
DatepickerMinimalPerf.default 45883 47288 0.97:1
DropdownManyItemsPerf.default 690 712 0.97:1
HeaderMinimalPerf.default 371 382 0.97:1
ListWith60ListItems.default 646 669 0.97:1
RosterPerf.default 1143 1182 0.97:1
Image.Fluent 371 382 0.97:1
ChatMinimalPerf.default 610 636 0.96:1
ProviderMinimalPerf.default 1031 1071 0.96:1

@@ -22,6 +22,10 @@ export const CardStyles = css`
:host(:focus-within) {
--elevation: 8;
}

:host * {
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be on every element within the host? I've tested this simply using :host {} and that works perfectly. I'd prefer to not use the * selector here if we don't have to - hiding the element itself should be enough.

Suggested change
:host * {
:host {

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question from me.

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, :host {} is also fine if we want to control elements behavior as possible as we can, I agree.

@chrisdholt
Copy link
Member

Thanks for the contribution @lqs469! Just one thing needed to pass the build and one request to modify the CSS selector.

@@ -22,6 +22,10 @@ export const CardStyles = css`
:host(:focus-within) {
--elevation: 8;
}

:host * {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question from me.

@lqs469
Copy link
Contributor Author

lqs469 commented Apr 23, 2021

image
Hi maintainers, Seems the build is blocked by some CI check about React, But I never modify the React part, How can I avoid this?

@chrisdholt
Copy link
Member

image
Hi maintainers, Seems the build is blocked by some CI check about React, But I never modify the React part, How can I avoid this?

@lqs469 the name of the build process is specific to react, but it runs against this as well. The portion that's missing is running yarn change at the root of the repository to include a change file to the PR describing the change, etc.

@lqs469
Copy link
Contributor Author

lqs469 commented Apr 29, 2021

image
Hi maintainers, Seems the build is blocked by some CI check about React, But I never modify the React part, How can I avoid this?

@lqs469 the name of the build process is specific to react, but it runs against this as well. The portion that's missing is running yarn change at the root of the repository to include a change file to the PR describing the change, etc.

Thanks for heads up, have updated change file. Please take a look.

@chrisdholt chrisdholt merged commit 353aa20 into microsoft:master Apr 29, 2021
@chrisdholt
Copy link
Member

Thanks for the contribution @lqs469!

@msft-fluent-ui-bot
Copy link
Collaborator

🎉@fluentui/web-components@v0.21.0 has been released which incorporates this pull request.:tada:

Handy links:

miroslavstastny pushed a commit to miroslavstastny/fluentui that referenced this pull request May 5, 2021
…t#17907)

* feat: improve rendering performance by `content-visibility`

Add the CSS `content-visibility` to fluent-card of web-component. This style will avoid some unnecessary rendering processes when the components are not in the viewport.
It will improve the performance of the page, like some feeds flow or multiple cards grid.

* chore: fluent-card host style

* Change files

Co-authored-by: Allen Lee <qinshuoli@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants