bug: ion-select with a long list of options is slow to open

Ouverte
#31,658 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
48/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
typescript

Piste de recherche

Start with the ion-select popover and ion-radio-group implementation in the Ionic Framework repository, then inspect how experimentalSlotFixes affects option insertion; the issue provides a reproduction repo and links Stencil issue 6973 with performance findings. Compare opening times with 50 and 250 options under 4x CPU throttling. Done means opening scales roughly with option count and the page stays responsive; the proposed shadow DOM change may affect app styling and need a major release.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

package: core type: bug
Prerequisites
Ionic Framework Version

v9.x

Current Behavior

An ion-select with the popover interface takes much longer to open as its list of options grows, and the page is unresponsive for most of that time.

With a full ISO country list of 249 options, it took 1,266ms to open with the CPU slowed down 4x in Chrome 155, compared with 203ms for a 50 option list. The page was unresponsive for 1,133ms of that time. I found out that each new option takes longer to add than the one before it did!

Expected Behavior

Each option should take about the same time to add, so opening the select with 250 options takes at most about five times as long as with 50, and the page should stay responsive while it's opening.

Steps to Reproduce
  1. Clone the reproduction repo from https://github.com/denodell/ionic-select-slow-open-repro
  2. Run npm install, then npm start, and open the page it serves.
  3. In Chrome's developer tools, set CPU throttling to 4x in the Performance panel.
  4. Click "Use 50 options", then click the select to open it. Close it.
  5. Click "Use 250 options", then click the select to open it again.
  6. The table I put on the page shows measurements of how long each took to open, and the longest frame length while it opened. With 250 options it takes four to five times as long as with 50!
Code Reproduction URL

https://github.com/denodell/ionic-select-slow-open-repro

Ionic Info

@ionic/core 9.0.7, Chrome 155. The reproduction repo doesn't use the Ionic CLI, so there's no output from ionic info.

Additional Information

The actual reason for this happening is Stencil's replacement appendChild function, which experimentalSlotFixes enables. Because ion-radio-group doesn't use shadow DOM, each new ion-radio causes Stencil to check all the existing options in the group twice, once to find the right slot and once to work out where the new one goes. You can see this in a Performance panel recording of the select opening, where most of the time taken is in Stencil's runtime, with its replacement appendChild taking around half of the total time.

I've raised that already with the Stencil team here: https://github.com/stenciljs/core/issues/6973

On Ionic's side, giving ion-radio-group shadow DOM would avoid it, since the browser would handle the slots. I realize that changes how apps can style the group, so it might need to wait for a major release.

Langage dominant
TypeScript
Étoiles
52.8k
Forks
13.3k
Merge moyen
3 j 1 h
PR mergées (30 j)
86

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de ionic-team/ionic-framework

Toutes les issues de ionic-team/ionic-framework

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.