NativeScript: ListView causing app to crash

From @tsonevn on August 9, 2018 6:18

From @vtrifonov on August 8, 2018 15:7

From @ludcila on August 8, 2018 14:21

Please, provide the details below:

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

Yes

Found some similar issues:

Tell us about the problem

The app crashes when:

  1. Using a ListView with multiple templates
  2. There is a model update that causes an item to switch from one template to another
  3. The app is put into background and/or navigation occurs (using slide transition)

Please provide the following version numbers that your issue occurs with:

  • CLI: 4.1.2
  • Cross-platform modules: 4.1.1
  • Runtime(s): 4.1.3

This seems to happen only on Android 8.0.

Did the error happen while the app was being constructed? (buildtime error)

No

Did the error happen while the app was executing? (runtime error)

Yes

An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException: 
Calling js method getView failed

Error: There is no entry with key 'org.nativescript.widgets.StackLayout{4b534d0 V.E...... ........ 0,-133-1080,28}' in the realized views cache for template with key'visited'.
File: "file:///data/data/org.nativescript.nsissue741/files/app/tns_modules/tns-core-modules/ui/list-view/list-view.js, line: 241, column: 20

StackTrace: 
	Frame: function:'ZoneAwareError', file:'file:///data/data/org.nativescript.nsissue741/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 1298, column: 33
	Frame: function:'ListViewAdapter.getView', file:'file:///data/data/org.nativescript.nsissue741/files/app/tns_modules/tns-core-modules/ui/list-view/list-view.js', line: 241, column: 27


	at com.tns.Runtime.callJSMethodNative(Native Method)
	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
	at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
	at com.tns.Runtime.callJSMethod(Runtime.java:970)
	at com.tns.Runtime.callJSMethod(Runtime.java:954)
	at com.tns.Runtime.callJSMethod(Runtime.java:946)
	at com.tns.gen.android.widget.BaseAdapter_view_195_32_ListViewAdapter.getView(BaseAdapter_view_195_32_ListViewAdapter.java:52)
	at android.widget.AbsListView.obtainView(AbsListView.java:2428)
	at android.widget.ListView.makeAndAddView(ListView.java:2083)
	at android.widget.ListView.fillUp(ListView.java:829)
	at android.widget.ListView.fillGap(ListView.java:766)
	at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5520)
	at android.widget.ListView.trackMotionScroll(ListView.java:1991)
	at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3660)
	at android.widget.AbsListView.onTouchMove(AbsListView.java:4086)
	at android.widget.AbsListView.onTouchEvent(AbsListView.java:3904)
	at android.view.View.dispatchTouchEvent(View.java:11788)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2647)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2974)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2661)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2974)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2661)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2974)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2661)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2974)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2661)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2974)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2661)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2974)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2661)
	at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:549)
	at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1953)
	at android.app.Activity.dispatchTouchEvent(Activity.java:3548)
	at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:502)
	at android.view.View.dispatchPointerEvent(View.java:12027)
	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5278)
	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5067)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4581)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4634)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4600)
	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4727)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4608)
	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4784)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4581)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4634)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4600)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4608)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4581)
	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7169)
	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7143)
	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7104)
	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7325)
	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:192)
	at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
	at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:181)
	at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:7248)
	at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:7353)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:981)
	at android.view.Choreographer.doCallbacks(Choreographer.java:790)
	at android.view.Choreographer.doFrame(Choreographer.java:715)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967)
	at android.os.Handler.handleCallback(Handler.java:808)
	at android.os.Handler.dispatchMessage(Handler.java:101)
	at android.os.Looper.loop(Looper.java:166)
	at android.app.ActivityThread.main(ActivityThread.java:7425)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

Please tell us how to recreate the issue in as much detail as possible.

Sample project to reproduce the issue: https://github.com/ludcila/ns-listview-issue

Copied from original issue: NativeScript/android-runtime#1145

Copied from original issue: NativeScript/NativeScript#6166

Copied from original issue: NativeScript/nativescript-angular#1479

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (13 by maintainers)

Most upvoted comments

I’ve reopened this issue as I have identified this still happens on very rare occasions where the items where updated while the view is in a suspended state (different page, app on background, screen turned off…).

I’ve identified the issue and should open a PR shortly to address it.

@spstratis - I don’t speak for the Progress or the NativeScript team – but I’ve been around since the beginning. 😁 But no one supports the ancient versions (v6.3 is 13 releases since the last 5.4, some major) – the whole objective of NativeScript is to move forward. Which means bugs in v5 will remain unfixed in v5 unless you manually fix it yourself or you pay someone (Progress has enterprise contracts, nStudio has service contracts).


As for the plugins – yes, you are correct multiple plugins went behind the paywall; because none of those developers get paid (except now via the proplugins) for any time spent on them, and none of the community was really helping support them. So all the work to maintain those 40+ plugins is being done by a very small group of people taking time from their families for no benefit. Now, at least these developers now make a little bit of cash each month to justify doing all this work.

But considering most companies spend somewhere between 30k-200k per year for a developer; and ALL 40+ plugins are only $120 total a year. The amount of time a developer wastes staying on NS 5, vs upgrading will cost way way more in labor than a yearly fee. Example: Say you, a developer made 100k a year. (numbers ignoring all the extra money a company spends on you for taxes, health, and other benefits the company offers) That developer wasting just 3.5 hours on a single NS 5 issue that is fixed in NS 6, is enough to have paid for the entire year’s plugin subscription. 😀

The cost of a subscription vs a developers labor cost is truly a steal and on top of that those that do subscribe help pay for the ongoing costs of maintenance on all these plugins so they continue to work in the future too. Pretty much a win-win scenario for everyone involved.

@NickIliev It appears this bug was fixed in a newer version of the NS core-modules and framework. For those of us not able to upgrade to 6.x core-modules at this time, is @romandragan or @edusperoni work around the only valid way to go?

@NickIliev, I’m still having that issue with 5.4.0 Android runtime.

When I’m trying to use multiple templates within ListView the app crashes with:

System.err: com.tns.NativeScriptException: 
System.err: Calling js method getView failed
System.err: 
System.err: TypeError: Cannot read property 'get' of undefined
System.err: File: "file:///data/data/app.feedme.mobile/files/app/vendor.js, line: 110398, column: 62
System.err: 
System.err: StackTrace: 
System.err: 	Frame: function:'ListViewAdapter.getView', file:'file:///data/data/app.feedme.mobile/files/app/vendor.js', line: 110398, column: 63
...