Skip to content

Performance issue in creating ion-select of 250 options #17641

Description

@YugoBekitzur

Bug Report

Ionic version:

[x] 4.0.1

Current behavior:

tested only on Android

I see a delay in almost 2 seconds when navigating to the page, containing a select with 250 options (countries list). I made a short performance research through Chrome Performance tab. 1.58 s took rendering this list.

Snapshot from performance test:

e.selectOptionChanged - 1.6222s
     ...
         e.loadOptions - 1.5872s

Expected behavior:

It should take at least twice less than it is now.
I don't think, I faced this issue working with ionic 3.

Related code:
CountriesService is initialised on app start and keeps countries in service until requested. So it doesn't take any time to retrieve countries on pages, where it's used

@Injectable()
export class CountriesService {
  private readonly countryStorageKey = 'countries';
  private _countries: ICountry[] = [];

  constructor(private http: HttpService, private storageService: StorageService) {
    this.storageService.getItem(this.countryStorageKey)
      .pipe(
        catchError(err =>
          this.http.get(`${environment.apiPath}dict/countries`, {}, false)
            .pipe(map((response: any) => response.docs))
        ),
      )
      .subscribe(dict => (this._countries = dict));
  }

  get countries(): ICountry[] {
    return this._countries;
  }
}

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.10.2 (/Users/user/.nvm/versions/node/v8.10.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.1
   @angular-devkit/build-angular : 0.12.4
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 7 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/user/Library/Android/sdk)
   ios-deploy        : 2.0.0
   ios-sim           : 7.0.0
   NodeJS            : v8.10.0 (/Users/user/.nvm/versions/node/v8.10.0/bin/node)
   npm               : 6.5.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.1 Build version 10B61

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions