element-portable/src/components/views
Eric Eastwood 3572b36648
Fix room list being laggy while scrolling 🐌 (#7939)
Fix https://github.com/vector-im/element-web/issues/21262

Optimizations:

 1. Don't update the `style` (positioning) of hidden tooltips
 1. Don't add DOM elements to the page for hidden tooltips

> ## Performance problems broken down
>
>
> ### Hidden tooltips rendering on `scroll`
>
> You can see that the Tooltip render is attached to the `scroll` event  at [`src/components/views/elements/Tooltip.tsx#L78-L81`](31f0a37ca2/src/components/views/elements/Tooltip.tsx (L78-L81))
>
> The rendering calls [`src/components/views/elements/Tooltip.tsx#L101` -> `updatePosition`](36adba101c/src/components/views/elements/Tooltip.tsx (L101)) which ends up as an expensive "Recalculate Style" because it uses [`Element.getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). This happens many many times within a single `scroll` event. Probably once for each tooltip within the room list **even though no tooltips are event visible as I scroll**. I can see that we're just updating the `style` attribute for a bunch of `.mx_Tooltip_invisible` elements at the end of the document.
>
> Each one of the purple spans below the `scroll` span ends up as a call to `updatePosition`. And a `scroll` event takes 35ms to 60ms to complete which is way over the 16.6ms 60 FPS budget (on a powerful desktop PC), granted these times are with the performance profiling running. This is without the Passbolt extension explained below.
>
> And the room list contains about 141 rooms (`document.querySelectorAll('.mx_RoomTile').length`):
>
> ![](https://user-images.githubusercontent.com/558581/156273551-e744d3d6-93c6-4b07-bb12-6aad361f96a2.png)
>
>
>
> ### Passbolt Chrome browser extension exacerbates the problem
>
> In order to login to Passbolt, it requires a browser extension which defaults to mucking up all pages:
>
> <img src="https://user-images.githubusercontent.com/558581/156275644-bc26b1f5-5d99-4eae-b74b-c2028f2f1baf.png" width="300">
>
>
> The extension source seems to be available: https://github.com/passbolt/passbolt_browser_extension
>
> The Passbolt Chrome extension has a `MutationObserver` listening to all attribute and element changes to the whole `<body>` of the `document` so it can `findAndSetAuthenticationFields` (find form elements and autofill).
>
>
> [`passbolt/passbolt_styleguide` -> `src/react-web-integration/lib/InForm/InFormManager.js#L143`](1c5eddc910/src/react-web-integration/lib/InForm/InFormManager.js (L143))
> ```js
> this.mutationObserver.observe(document.body, { attributes: true, childList: true, subtree: true });
> ```
>
> This causes a bunch of `Forced reflow` because the Tooltip `updatePosition` is mutating the element `style` attribute and Passbolt `MutationObserver` callbacks are querying the whole DOM looking for form elements all in the same frame.
>
> Under the `scroll` event, all of the little spans are the `MutationObserver` -> `findAndSetAuthenticationFields`. With the Passbolt extension, scrolling is verrrrry crunchy and bad.
>
> ![](https://user-images.githubusercontent.com/558581/156144998-8cf7686f-3c7b-42f8-8d81-ff780bae0ab5.png)
>
>
> #### Workaround
>
> Instead of running Passbolt on all sites, we can enable the extension to only run on the domain for Passbolt instance itself. I'm guessing the Passbolt extension also does autofill stuff on sites but I always login manually to the Passbolt instance so this solution works for me �
>
> **Extensions** -> **Passbolt** -> **Details** -> Change **Site access** to `On specific sites` -> Enter in your Passbolt instance `https://passbolt.example.com/`
>
> ![](https://user-images.githubusercontent.com/558581/156275630-a53ef6a1-c058-4ac9-aa08-ae50b90e72c9.png)
>
> *-- https://github.com/vector-im/element-web/issues/21262*
2022-03-02 13:20:01 -06:00
..
audio_messages dont re-prepare voice messages (#7897) 2022-03-01 09:43:32 +01:00
auth Remove Countly analytics integration (#7808) 2022-02-15 16:58:30 +00:00
avatars replace all require(svgs) with esm import (#7948) 2022-03-02 17:14:33 +01:00
beta Improve accessibility of the BetaPill (#7949) 2022-03-02 16:31:47 +00:00
context_menus replace all require(svgs) with esm import (#7948) 2022-03-02 17:14:33 +01:00
dialogs replace all require(svgs) with esm import (#7948) 2022-03-02 17:14:33 +01:00
directory Improve ThreadPanel ctx menu accessibility (#7217) 2021-11-29 17:42:53 +00:00
elements Fix room list being laggy while scrolling 🐌 (#7939) 2022-03-02 13:20:01 -06:00
emojipicker Autofocus correct composer after sending reaction (#7950) 2022-03-02 16:31:34 +00:00
groups replace all require(svgs) with esm import (#7948) 2022-03-02 17:14:33 +01:00
host_signup Auto fix 2021-10-22 17:23:37 -05:00
location Fix sending locations into threads and fix i18n (#7943) 2022-03-02 14:27:16 +00:00
messages Revert "remove code related to encrypted file download button in iframe" (#7957) 2022-03-02 18:27:36 +01:00
right_panel Add a few more UIComponent flags, and ensure they are used in existing code (#7937) 2022-03-02 10:37:18 -07:00
room_settings Fix publishing address wrongly demanding the alias be available (#7690) 2022-02-01 15:06:26 +00:00
rooms Add a few more UIComponent flags, and ensure they are used in existing code (#7937) 2022-03-02 10:37:18 -07:00
settings replace all require(svgs) with esm import (#7948) 2022-03-02 17:14:33 +01:00
spaces Make "Match system" on QuickThemeSwitcher.tsx translatable (#7951) 2022-03-02 16:10:14 +00:00
terms Merge branch 'develop' into sort-imports 2021-12-09 08:34:20 +00:00
toasts Improve typing around event emitter handlers (#7816) 2022-02-22 12:18:08 +00:00
typography Add Heading components (#7362) 2021-12-15 11:00:10 +01:00
verification Consistently use the word "device", rather than "session" or "login", in verification dialog (#7474) 2022-01-06 16:57:49 -05:00
voip Remove log line to try to fix freeze on answering VoIP call (#7883) 2022-02-23 19:10:36 +00:00