nativescript-community / ui-collectionview

Allows you to easily add a collection view (grid list view) to your projects. Supports vertical and horizontal modes, templating, and more.
Apache License 2.0
59 stars 18 forks source link

ui-collectionview 4.0.48 throws TypeError on android #36

Closed NachmanRoss closed 2 years ago

NachmanRoss commented 2 years ago

I updated to the latest version 4.0.48 and it throws the following error on my android eulator:

JS: TypeError: Cannot read property 'scrollListener' of undefined JS: disposeNativeView(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript-community/ui-collectionview/index.android.js:278:0) JS: at _tearDownUI(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view-base/index.js:657:0) JS: at (file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view-base/index.js:632:0) JS: at eachChildView(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) JS: at eachChild(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view/view-common.js:759:0) JS: at _tearDownUI(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view-base/index.js:631:0) JS: at (file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view-base/index.js:632:0) JS: at eachChildView(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/layouts/layout-base-common.js:101:0) JS: at eachChild(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view/view-common.js:759:0) JS: at _tearDownUI(file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view-base/index.js:631:0) JS: at (file: app/webpack:/com.benalterdevelopment.kavohr/node_modules/@nativescript/core/ui/core/view-base/index.js:632:0) JS: at eachChi... JS: com.tns.NativeScriptException: Calling js method run failed

When I rollback to the 4.0.47 version and do a clean and then rebuild everything is ok again.

My nativescript is up to date with the latest versions of core and android.

farfromrefug commented 2 years ago

@NachmanRoss thanks for the report. It is weird nothing has changed in this code. Plus the disposing works fine here with latest. I will need more info on your app.

NachmanRoss commented 2 years ago

My app is a pure typescript app and I didn't make any changes other than updating the plugin. However on the page's onNavigatingTo function I do register the page's viewModel for an OrientationChange event which updates the observables on the page. Maybe that's triggering something although the error is thrown when the app is displaying for the first time on the emulator before I rotate the emulator. The page itself has the following:

  <StackLayout width="100%" height="100%">
    <GridLayout rows="*" columns="*, *, *" width="100%" height="{{ cardWidth }}"
      visibility="{{ logoVisibility }}">
      <Label row="0" col="1" class="image-background" textWrap="true" textAlignment="center"
        backgroundImage="{{ logo }}" width="{{ cardWidth }}"/>
    </GridLayout>
    <GridLayout width="100%" height="100%" rows="*">
      <cv:CollectionView id="list-view" items="{{ menu }} " marginTop="10" marginBottom="30"
        colWidth="{{ colWidth }}" rowHeight="200" marginLeft="1%" itemTap="{{ onTap }}">
        <cv:CollectionView.itemTemplate>
          <StackLayout orientation="horizontal">
            <StackLayout orientation="vertical" width="97%" marginTop="2">
              <Label class="image-background" textWrap="true" textAlignment="center"
                backgroundImage="{{ background }}"
                height="85%" style="border-radius: 15;border-width: 0;">
              </Label>
              <Label text="{{ title }}" class="body-text" color="white" textAlignment="center" />
            </StackLayout>
          </StackLayout>
        </cv:CollectionView.itemTemplate>
      </cv:CollectionView>
    </GridLayout>
  </StackLayout>
farfromrefug commented 2 years ago

@NachmanRoss there is an issue there. The bug you have is caused by disposeNativeView which means destroying the collectionview. It should not be called while opening the app. I am not sure what s going on but from here i cant help as i cant reproduce. If you can create a simple repro example then i can help

NachmanRoss commented 2 years ago

I’m not doing anything that explicitly destroys the collection view but maybe the orientation change event is. I’ll see if I can debug first by pulling out the OrientationChange event and see if the error goes away with the new release of the plugin. It is weird because my code hasn’t changed at all and the previous release of the plugin works perfectly.

Nachman Beinish Ross On Nov 25, 2021, 7:18 AM -0500, farfromrefuge @.***>, wrote:

@NachmanRoss there is an issue there. The bug you have is caused by disposeNativeView which means destroying the collectionview. It should not be called while opening the app. I am not sure what s going on but from here i cant help as i cant reproduce. If you can create a simple repro example then i can help

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nativescript-community/ui-collectionview/issues/36#issuecomment-979163333 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUWSSYHD5UE4S7HTWW3373UNYSRVANCNFSM5IYIFRDQ . https://github.com/notifications/beacon/AKUWSS7MF4LBUHLOAZNH6A3UNYSRVA5CNFSM5IYIFRD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHJONRRI.gif

NachmanRoss commented 2 years ago

I retested with the new release and the page is working again after doing another clean and rebuild. I'm not sure what the issue was since I did more than one clean and rebuild but it is working now so close this issue.