pull_requests: 619901306
This data as json
id | node_id | number | state | locked | title | user | body | created_at | updated_at | closed_at | merged_at | merge_commit_sha | assignee | milestone | draft | head | base | author_association | auto_merge | repo | url | merged_by |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
619901306 | MDExOlB1bGxSZXF1ZXN0NjE5OTAxMzA2 | 5201 | closed | 0 | Fix lag in Jupyter caused by CSS in `_repr_html_` | 12912489 | ## What The CSS used by `_repr_html_` (for displaying objects in Jupyter) placed font colors in `:root` as CSS custom properties. This seems to cause lag in notebooks with more than a couple of dozens of cells when running a cell that displays outputs. We observed this on Chrome and Firefox, so it is probably not browser-specific. ## To reproduce - In a new notebook, create a simple array: ```python import xarray as xr import numpy as np data = np.random.rand(4) a = xr.DataArray(data, coords=[np.arange(4)], dims=['x']) ``` - From a second cell, display `a`: ```python a ``` This is probably fast with no noticable lag. - Add 50-100 more cells. They CAN be empty. Run the second cell again. You may notice a small lag before the array is displayed, which can exceed 1 second in some cases (depending on number of cells in the notebook, and probably the type of hardware the browser is running on, it is clearly visible on my 2015 Macbook Pro). - Probably other UI interactions such as switching tabs are also affected, but there the effect is not entirely clear. ## Fix - Set CSS custom properties not in `:root` but the top-level class `xr-wrap`. - TODO: I think the `vscode-dark` settings also may need to change, but my understanding of CSS is too limited. Can someone suggest how to fix this or take care of it? ## Discussion Interestingly we ran into this problem independently of xarray: While `scipp` borrowed an early draft of `xarrays`'s `_repr_html_` implementation (thanks!), this was *before* the color configs were placed into `:root` --- we just happened to add such a color config independently. Since this was a recent change we managed to find the culprit yesterday (https://github.com/scipp/scipp/pull/1847). And then it occurred to me to check whether xarray has the same problem... So this makes me think that *other* projects that define `_repr_html_` may well suffer from the same problem. Can we do anything to spread the word, or better, could there be a way to fix this for everyone (in Jupyter)? ## Checklist <!-- Feel free to remove check-list items aren't relevant to your change --> - [x] Passes `pre-commit run --all-files` - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` | 2021-04-21T06:46:28Z | 2023-03-28T04:21:43Z | 2023-03-28T04:21:43Z | 7377a1b91be0d91078ae05f0a6bb7132e213f219 | 0 | c1d75ab0c7cb99227e17f63e15b5b043661912c7 | d1e4164f3961d7bbb3eb79037e96cae14f7182f8 | NONE | 13221727 | https://github.com/pydata/xarray/pull/5201 |
Links from other tables
- 2 rows from pull_requests_id in labels_pull_requests