[TIMOB-24686] Calling getWindow() on a null Activity reference
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Caio Iglesias |
Assignee | Unknown |
Created | 2017-05-11T12:38:16.000+0000 |
Updated | 2018-02-28T19:55:16.000+0000 |
Description
I have been eventually getting a crash with this exception:
lang.java.NullPointerException: (Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference)
at proxy.titanium.appcelerator.org.TiViewProxy.handleMessage(TiViewProxy.java:323)
at proxy.titanium.appcelerator.org.TiWindowProxy.handleMessage(TiWindowProxy.java:116)
at ui.titanium.modules.ti.WindowProxy.handleMessage(WindowProxy.java:453)
at os.android.Handler.dispatchMessage(Handler.java:98)
at os.android.Looper.loop(Looper.java:145)
at app.android.ActivityThread.main(ActivityThread.java:5951)
at reflect.lang.java.Method.invoke(Native Method)
at reflect.lang.java.Method.invoke(Method.java:372)
at os.internal.android.com.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at os.internal.android.com.ZygoteInit.main(ZygoteInit.java:1195)
I checked [proxy.titanium.appcelerator.org.TiViewProxy's handleMessage method](https://github.com/appcelerator/titanium_mobile/blob/a8aceeaeee02ed9c8ea70c835a0e78960e254a55/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L227) and it indeed calls getWindow() on what is returned by TiApplication.getAppCurrentActivity(), on [MSG_GETSIZE](https://github.com/appcelerator/titanium_mobile/blob/a8aceeaeee02ed9c8ea70c835a0e78960e254a55/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L296) and on [MSG_GETRECT](https://github.com/appcelerator/titanium_mobile/blob/a8aceeaeee02ed9c8ea70c835a0e78960e254a55/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L323). The [docs](http://docs.appcelerator.com/module-apidoc/latest/android/org/appcelerator/titanium/TiApplication.html) state that TiApplication.getAppCurrentActivity() returns ??the current activity if exists. Otherwise, the thread will wait for a valid activity to be visible.??, but [it does in fact return null](https://github.com/appcelerator/titanium_mobile/blob/11ce8248edb5d821d18e1c3217bf06b99c96d33f/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java#L294) if no Activity is present.
No comments