Skip to content
This repository was archived by the owner on May 4, 2022. It is now read-only.
This repository was archived by the owner on May 4, 2022. It is now read-only.

[Virtual Scroll] null is not an object (evaluating 'ev.scrollTop') caused by isScrolling race condition #967

@m1aw

Description

@m1aw

I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request

Current behavior:

Virtual Scroll stops updating the item position after crashing with TypeError: null is not an object (evaluating 'ev.scrollTop').

Expected behavior:

VirtualScroll scrollUpdate should verify if the event is null and not crash.

Steps to reproduce:

Have a scenario where multiple scrollTo might be callled.

Related code:

As far as I was able to debug it is caused by a null being emitted by the ScrollView in the setScrolling method. It happens because scrollTo starts the scroll loop when this.isScrolling still active with causes both isScrolling and is this.isScrolling to be true and a onScroll event to be emited with the null value, with causes VirtualScroll.scrollUpdate to crash when tries to access ev.scrollTop.

setScrolling(isScrolling: boolean, ev: ScrollEvent) {
    if (this.isScrolling) {
      if (isScrolling) {
        this.onScroll && this.onScroll(ev);
      } else {
        this.isScrolling = false;
        this.onScrollEnd && this.onScrollEnd(ev);
      }
    } else if (isScrolling) {
      this.isScrolling = true;
      this.onScrollStart && this.onScrollStart(ev);
    }
  }
 scrollUpdate(ev: ScrollEvent) {
  // set the scroll top from the scroll event
  this._data.scrollTop = ev.scrollTop;

  // there is a queue system so that we can
  // spread out the work over multiple frames
  const queue = this._queue;
  if (queue === ScrollQueue.NoChanges) {
    // no dom writes or change detection to take care of
    this._stepNoChanges();
  } else if (queue === ScrollQueue.ChangeDetection) {
    this._dom.write(() => this._stepChangeDetection());
  } else {
    assert(queue === ScrollQueue.DomWrite, 'queue value unexpected');
    // there are DOM writes we need to take care of in this frame
    this._dom.write(() => this._stepDOMWrite());
  }
}

Other information:

Ionic info:

ionic info

cli packages: (--REDACTED--)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.1.0 

local packages:

    @ionic/app-scripts : 3.2.0
    Cordova Platforms  : android 6.4.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v11.0.0
    npm               : 6.4.1 
    OS                : Linux 4.18

Environment Variables:

    ANDROID_HOME : /opt/android-sdk

Misc:

    backend : pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions