Nativescript: ListView with ItemTemplates in TabView-Item-Frame after navigation with animation

Created on 19 Nov 2019  路  9Comments  路  Source: NativeScript/NativeScript

Environment

  • CLI: 6.1.2
  • Cross-platform modules: 6.2.1
  • Android Runtime: 6.2.0
  • iOS Runtime: 6.2.0
  • Plugin(s): -

Describe the bug

The bug is a runtime error on Android OS.
It only occurs if the navigation is performed within a frame of a TabViewItem using the animation-type "slide".
If the animation is disabled or performed outside of a TabView the error does not ossur.
After a navigation to the page containing the ListView (with slide animation) the app must be put to background and activated again.
A tap on the first list entry "destroys" the Layout (using ListViews ItemTemplates).
A second tap crashes the app:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onItemClick failed
System.err: TypeError: Cannot read property 'get' of undefined
System.err:
System.err: StackTrace:
System.err:     ItemClickListenerImpl.onItemClick(file:///node_modules\tns-core-modules\ui\list-view\list-view.js:28:0)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1209)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1096)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1083)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1063)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1055)
System.err:     at com.tns.gen.java.lang.Object_vendor_31981_32_ItemClickListenerImpl.onItemClick(Object_vendor_31981_32_ItemClickListenerImpl.java:26)
System.err:     at android.widget.AdapterView.performItemClick(AdapterView.java:318)
System.err:     at android.widget.AbsListView.performItemClick(AbsListView.java:1159)
System.err:     at android.widget.AbsListView$PerformClick.run(AbsListView.java:3136)
System.err:     at android.widget.AbsListView$3.run(AbsListView.java:4052)
System.err:     at android.os.Handler.handleCallback(Handler.java:873)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
System.err:     at android.os.Looper.loop(Looper.java:193)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

To Reproduce

  1. Start the application
  2. Tap the button "navigation-animation-slide"
  3. Put the app in background by pressing the home button
  4. Bring the app back to foreground (recent apps)
  5. Tap the first item of the List
  6. A second tap crashed the app

AppStart:
Screenshot_1574156233
After Navigation:
Screenshot_1574156241
Press Home Button and Activate App (recent apps):
Screenshot_1574156276
Tap the first item:
Screenshot_1574156291
Result:
Screenshot_1574156295
Second tap:
Screenshot_1574156299

Expected behavior

The ListViews ItemTemplate should work.

Sample project

ListViewTemplates.zip

Additional context

https://github.com/NativeScript/NativeScript/issues/6284

https://stackoverflow.com/questions/50901650/nativescript-list-view-crash-using-android

bug android

All 9 comments

Hi @kdagithub,
Thank you for the provided sample project. I was able to recreate the issue also, without the usage of TabView component. I am attaching the sample app with some edits. On that matter, I will mark this as a bug and we will investigate further the case. For now, I would suggest keeping track of the problem for further info.
Archive.zip

@tsonevn
Is there any update on this issue? Basically the ListView with itemTemplateSelector is not usable after any navigation. Even without animation.

Update:
Upgrading vom tns 6.1.2 -> 6.2.0 introduces the bug.

tns 6.1.2 works as expected:
working.zip

after tns update 6.2.0 the itemTemplate seems buggy:
failing.zip

+1

This fails even without animations. This happens with the latest v6 version. And the file index.android.ts inside the list-view has not changed much (at least not the one in master with the one that I currently have).

@NathanaelA @NathanWalker Any workarounds? RadListView sadly is not an option for me...

@diegovincent for now I advise you to use nativescript-collectionview for 6.x or @nativescript-community/ui-collectionview for 7.x

@farfromrefug Okay, it might be a suitable solution. However, do you know if that plugin could be used to implement a list view with sticky headers? Which is what I have done with the List View using the android.widget.ListView and UITable native API calls...

@diegovincent very interested to know how you did it. But yes it is doavle though not implemented yet.

Still an issue on 7.x, I am unable to reproduce it myself, but I can see it happening in logs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nirsalon picture nirsalon  路  3Comments

guillaume-roy picture guillaume-roy  路  3Comments

minjunlan picture minjunlan  路  3Comments

kn9ts picture kn9ts  路  3Comments

Pourya8366 picture Pourya8366  路  3Comments