Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25636] Android: Calling ScrollableView's setters causes a crash if parent window is closed as of 7.0.0

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-05-16T00:00:27.000+0000
Affected Version/sRelease 7.0.1
Fix Version/sRelease 7.3.0
ComponentsAndroid
LabelsScrollableView, android
ReporterAminul Islam
AssigneeJoshua Quick
Created2017-12-28T16:44:50.000+0000
Updated2018-05-16T00:00:30.000+0000

Description

Hi, We are migrating our app from 6.3.0GA Ti SDK to 7.0.0.GA SDK and we are facing couple of issues: 1. In a window, we are using scrollable view and on close of window we are emptying the views of scrollable view by using scrollableView.views = []. with 6.3.0.GA it is working fine but with 7.0.0.GA we are getting error stating
“TiApplication: (main) [16638,27440] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to destroy activity {com.hthworldwide.GeoBlue/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void ti.modules.titanium.ui.widget.TiUIScrollableView.setViews(java.lang.Object)' on a null object reference; Titanium 7.0.1,2017/12/18 10:42,undefined”
2. In a window, we are using activity indicator and on close of that window we are hiding activity indicator by activityIndicator.hide(). with 6.3.0.GA it is working fine but with 7.0.0.GA we are getting error stating
“TiApplication(16766): (main) [21008,142400] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'void ti.modules.titanium.ui.widget.TiUIActivityIndicator.hide()' on a null object reference; Titanium 7.0.1,2017/12/18 10:42,undefined”
Steps to reproduce the issues: 1. Create a sample classic project 2. Copy the attached files and paste them into resources folder 3. Run the App on android device 4. Click on the label “click to view scrollable window”, once window is opened click on android back button. 5. Click on label “click to show indicator”, once window is opened click on android back button. Note : This is an issue in android platform. Even tried with 7.0.1.GA sdk still we are facing these issues.

Attachments

FileDateSize
activityIndWin.js2017-12-28T16:43:41.000+0000847
app.js2017-12-28T16:43:41.000+0000567
ScrollableViewCloseTest.js2018-05-03T23:37:33.000+0000739
scrollableWin.js2017-12-28T16:43:41.000+0000831

Comments

  1. Joshua Quick 2018-01-05

    I'm able to reproduce this issue in Titanium 7.0.0 with the following code:
       var window = Ti.UI.createWindow();
       var scrollableView = Ti.UI.createScrollableView(
       {
       	views:
       	[
       		Ti.UI.createLabel({ text: "Page 1" }),
       		Ti.UI.createLabel({ text: "Page 2" }),
       		Ti.UI.createLabel({ text: "Page 3" }),
       		Ti.UI.createLabel({ text: "Page 4" }),
       	],
       	showPagingControl: true,
       });
       window.add(scrollableView);
       window.addEventListener("close", function(e) {
       	var view = Ti.UI.createView();
       	scrollableView.addView(view);
       	scrollableView.insertViewsAt(0, [Ti.UI.createView()]);
       	scrollableView.removeView(view);
       	scrollableView.moveNext();
       	scrollableView.movePrevious();
       	scrollableView.scrollToView(0);
       	scrollableView.currentPage = 1;
       	scrollableView.scrollingEnabled = false;
       	scrollableView.views = [];
       });
       window.open();
       
    *Result:* Crashes with exception...
       [WARN] :   W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void ti.modules.titanium.ui.widget.TiUIScrollableView.addView(org.appcelerator.titanium.proxy.TiViewProxy)' on a null object reference
       [WARN] :   W/System.err: 	at ti.modules.titanium.ui.ScrollableViewProxy.handleMessage(ScrollableViewProxy.java:114)
       [WARN] :   W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:101)
       [WARN] :   W/System.err: 	at org.appcelerator.kroll.common.TiMessenger.sendMessage(TiMessenger.java:323)
       [WARN] :   W/System.err: 	at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:289)
       [WARN] :   W/System.err: 	at org.appcelerator.kroll.common.TiMessenger.sendBlockingMainMessage(TiMessenger.java:164)
       [WARN] :   W/System.err: 	at ti.modules.titanium.ui.ScrollableViewProxy.addView(ScrollableViewProxy.java:176)
       [WARN] :   W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
       [WARN] :   W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
       [WARN] :   W/System.err: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:934)
       [WARN] :   W/System.err: 	at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:807)
       [WARN] :   W/System.err: 	at org.appcelerator.titanium.proxy.TiWindowProxy.closeFromActivity(TiWindowProxy.java:206)
       [WARN] :   W/System.err: 	at org.appcelerator.titanium.TiBaseActivity.onDestroy(TiBaseActivity.java:1518)
       [WARN] :   W/System.err: 	at org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:32)
       [WARN] :   W/System.err: 	at android.app.Activity.performDestroy(Activity.java:7177)
       [WARN] :   W/System.err: 	at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1248)
       [WARN] :   W/System.err: 	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4425)
       [WARN] :   W/System.err: 	at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4456)
       [WARN] :   W/System.err: 	at android.app.ActivityThread.-wrap5(Unknown Source:0)
       [WARN] :   W/System.err: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1654)
       [WARN] :   W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:105)
       [WARN] :   W/System.err: 	at android.os.Looper.loop(Looper.java:164)
       [WARN] :   W/System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6541)
       [WARN] :   W/System.err: 	at java.lang.reflect.Method.invoke(Native Method)
       [WARN] :   W/System.err: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
       [WARN] :   W/System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
       
    *Cause:* The native view has been released and null-out when its parent window was closed. The above code's setters and methods should no-op in this case. Note that this is not an issue in Titanium versions older than 7.0.0. *Work-Around:* Don't call the ScrollableView's setters and methods once its parent window has been closed. For example, you don't need to set its child views to [] to release the child references since their references are already released automatically.
  2. Joshua Quick 2018-01-06

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9696
  3. Joshua Quick 2018-05-03

    This issue is only reproducible in Titanium 7.0.0 and 7.0.1. This issue is not reproducible in 7.0.2 and 7.1.0. It was inadvertently fixed by a change in 7.0.2. Closing as resolved.

JSON Source