Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15872] Android: NPE at android.view.ViewConfiguration.get()

GitHub Issuen/a
TypeStory
PriorityMedium
StatusClosed
ResolutionNeeds more info
Resolution Date2014-09-02T22:15:54.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelslook1, triage
ReporterPhilippe Wueger
AssigneeHieu Pham
Created2013-11-14T10:45:24.000+0000
Updated2018-08-06T17:43:14.000+0000

Description

Problem

Google Play Crash reports contain multiple of the following NullPointerExceptions occuring at the same place:
java.lang.NullPointerException
at android.view.ViewConfiguration.get(ViewConfiguration.java:228)
at android.view.View.<init>(View.java:1888)
at android.view.ViewGroup.<init>(ViewGroup.java:281)
at android.widget.FrameLayout.<init>(FrameLayout.java:80)
at ti.modules.titanium.ui.widget.tableview.TiTableView.<init>(TiTableView.java:266)
at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:106)
at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1129)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:469)
at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:460)
at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:438)
at ti.modules.titanium.ui.TableViewProxy.getTableView(TableViewProxy.java:146)
at ti.modules.titanium.ui.TableViewProxy.handleSetData(TableViewProxy.java:689)
at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:866)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.view.ViewConfiguration.get(ViewConfiguration.java:230)
at android.view.View.<init>(View.java:1920)
at android.view.ViewGroup.<init>(ViewGroup.java:303)
at android.widget.FrameLayout.<init>(FrameLayout.java:80)
at ti.modules.titanium.ui.widget.tableview.TiTableView.<init>(TiTableView.java:266)
at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:106)
at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1129)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:469)
at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:460)
at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:438)
at ti.modules.titanium.ui.TableViewProxy.getTableView(TableViewProxy.java:146)
at ti.modules.titanium.ui.TableViewProxy.handleSetData(TableViewProxy.java:689)
at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:866)
at android.os.Handler.dispatchMessage(Handler.java:95)
at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:364)
at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:349)
at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:234)
at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:261)
at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:186)
at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:740)
at org.appcelerator.titanium.TiBaseActivity.onStop(TiBaseActivity.java:1058)
at org.appcelerator.titanium.TiLaunchActivity.onStop(TiLaunchActivity.java:355)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1272)
at android.app.Activity.performStop(Activity.java:4073)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3127)
... 11 more
Caused by: java.lang.NullPointerException
at android.view.ViewConfiguration.get(ViewConfiguration.java:228)
at android.view.View.<init>(View.java:1878)
at android.view.ViewGroup.<init>(ViewGroup.java:281)
at android.widget.FrameLayout.<init>(FrameLayout.java:80)
at ti.modules.titanium.ui.widget.tableview.TiTableView.<init>(TiTableView.java:266)
at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:106)
at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1129)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:469)
at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:460)
at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:438)
at ti.modules.titanium.ui.TableViewProxy.getTableView(TableViewProxy.java:146)
at ti.modules.titanium.ui.TableViewProxy.handleSetData(TableViewProxy.java:689)
at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:866)
at android.os.Handler.dispatchMessage(Handler.java:95)
at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:364)
at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:349)
at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:234)
at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:261)
at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:186)
at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:740)
at org.appcelerator.titanium.TiBaseActivity.onPause(TiBaseActivity.java:917)
at org.appcelerator.titanium.TiLaunchActivity.onPause(TiLaunchActivity.java:339)
at android.app.Activity.performPause(Activity.java:3851)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1191)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2345)
... 12 more

Test Case

Unfortunately, I haven't been able to find steps to reproduce this issue. The best way to go forward in my opinion is to analyze the code and to try and figure out from there, what is going wrong.

My Analysis

From the code I see, that in the TiTableViewConstructor a call to "super(proxy.getActivity())" is done. In "proxy.getActivity()" it is noted, that this may return "null". I assume that this would lead to the crash reports above. Could it be that we have a possible race condition or something similar here, where "proxy.getActivity()" is called, before the proxy actually has an activity assigned to it? Is anyone else seeing this problem on a large installation base? It would be great to improve the stability of Titanium further by fixing this issue.

Comments

  1. Hieu Pham 2013-12-06

    Hi Philippe, You're correct. Based on the log, this is looking like a timing issue. However, without a proper test case, we can't continue to investigate since timing issues are usually edge cases.
  2. Ingo Muschenetz 2013-12-16

    We unfortunately can't proceed any further without some form of test case. We'll be happy to revisit this once we have a better set of steps.
  3. Trevor Ward 2014-01-21

    We have hit this issue, I will try and get a use case in place
  4. Noah Lively 2014-05-23

    We are having the same problem. My stats are: - Titanium SDK 3.2.2 GA - Compiled and run on a Google Nexus 7 (2013 model) - App built in Alloy The error happens inconsistently. Is there some way I can debug? It happens beneath the JS layer where Titanium allows me to debug, so no amount of breakpoints are helping me. I know enough Java to where, given the right debug framework, I could probably find out what's happening. Please advise.
  5. Mike Fogg 2014-08-11

    I am seeing this issue as well (Titanium 3.3.0, tons of different phones, and anything from Android 4.0 to 4.4.4). After taking a look at the various lines being reported (most likely due to the different versions of Android and other Android customizations done by providers) it seems to me that the error is coming from:
       ...
       final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
       ...
       
    (https://github.com/android/platform_frameworks_base/blob/kitkat-mr2.2-release/core/java/android/view/ViewConfiguration.java#L352). It looks pretty clear to me that 'context' is probably null. Does anyone have any tips as to how to figure out what "context" is actually referring to here? Aka, which view is null? I'm grasping at straws here as breadcrumbs make it pretty clear that people are crashing on any one the tableviews in the app. I'm having a difficult time reproducing this as well but it seems to be happening a lot (unless I try to reproduce it :) ).
  6. Philippe Wueger 2014-08-12

    I also think that this problem is occurring because of a 'null' context. My current guess is, that this happens when the app is shutting down (no activity/context anymore) and for some reason there is still code run which instantiates UI objects (which would need an activity/context). I haven't yet managed to find a test case which reproduces this issue reliably.
  7. Ingo Muschenetz 2014-08-25

    [~hpham] to investigate.
  8. Allen Yeung 2014-09-02

    We need a concrete test case to be able to fully diagnose the issue here.
  9. Jason Priebe 2015-04-07

    This is one of our biggest crash issues on android as well. We have about 100,000 installs. It is too intermittent to reproduce, but happening much more than we would like in the wild. I don't know if we can build a test case for it, but I wish Appcelerator would take these seriously enough to investigate without a user-supplied test case.
  10. Alex Bernier 2015-05-12

    I also see a lot of crash reports for this issue. I just emailed ~50 of the users who got the crash to see if they remember what they were doing. I'll report back if I get any clues.
  11. Yishai Brown 2015-05-12

    Just got similar crash report from NewRelic on Galaxy S (GT-I9000) Android 4.4.2 (df752133aa). The app compiled with SDK 3.4.1 According to the stack, it is upon construction of a TableView. android.view ViewConfiguration.java line 313 in ViewConfiguration.get() android.view View.java line 3455 in View.() android.view ViewGroup.java line 459 in ViewGroup.() android.widget FrameLayout.java line 93 in FrameLayout.() ti.modules.titanium.ui.widget.tableview TiTableView.java line 274 in TiTableView.() ti.modules.titanium.ui.widget TiUITableView.java line 106 in TiUITableView.processProperties()
  12. Eric Merriman 2015-06-26

    Can anyone point me to an app where this occurs? I'd be happy to tray and make some headway on this ticket if we had a app to try. Sounds like many of you have publicly available apps where this occurs. Let me know the name of one or more and we can try to reproduce.
  13. Alex Bernier 2015-06-26

    [TwoGrand](https://play.google.com/store/apps/details?id=com.twogrand.twogrand) has it, but we don't yet have steps to reproduce.
  14. Jason Priebe 2015-06-26

    WRAL News has it. You're more than welcome to look in our dashboard and look at APM info.
  15. David Fox 2016-09-25

    Did anyone ever figure this out? I'm seeing the same error in my app and it seems to be very difficult to reproduce.
  16. Eric Merriman 2018-08-06

    Closing tickets that need more info from 2015 and earlier. Is this is in error, please reopen.

JSON Source