Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27434] Android: Re-layout of deeply nested views can cause performance issues as of 7.5.0

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-10-10T15:16:41.000+0000
Affected Version/sRelease 7.5.0
Fix Version/sRelease 8.2.1
ComponentsAndroid
Labelsandroid, engSchedule, regression, view
ReporterJoshua Quick
AssigneeJoshua Quick
Created2019-10-02T02:10:44.000+0000
Updated2020-10-05T08:19:23.000+0000

Description

*Summary:* If you have very deeply nested views (say 15 or more), then anything that causes them to be re-laid out can cause noticeable performance issues as of Titanium 7.5.0. *Steps to reproduce:*

Build and run the below code on Android.

Tap and hold on the text within the TextField.

Notice that the app hangs for a couple of seconds.

Rotate the device to landscape.

Notice that the app hangs for a couple of seconds.

var window = Ti.UI.createWindow();
var rootView = Ti.UI.createView({ width: Ti.UI.FILL, height: Ti.UI.FILL });
var topView = rootView;
for (var index = 0; index < 20; index++) {
	var nextView = Ti.UI.createView({ width: Ti.UI.FILL, height: Ti.UI.FILL });
	topView.add(nextView);
	topView = nextView;
}
var textField = Ti.UI.createTextField({
	value: "Hello World",
	width: "80%",
});
topView.add(textField);
window.add(rootView);
window.open();
*Cause:* This regression was introduced in 7.5.0 when we added the "extendSafeArea" and "safeAreaPadding" feature. The performance issue is caused by our Java [TiCompositeLayout.onApplyWindowInsets()](https://github.com/appcelerator/titanium_mobile/blob/3b925d3b89e0d59bf89b846bfa127e9656746dbf/android/titanium/src/java/org/appcelerator/titanium/view/TiCompositeLayout.java#L460) method when you have deeply nested views (say 15 or more layers). The dispatched window inset handling appears to get exponentially worse the more views you have nested. Especially since each child view that applies those insets triggers a request-layout. *Work-around:* Only known work-around is to not nest your views so deeply. Try not to nest more than 10 layers deep.

Comments

  1. Joshua Quick 2019-10-02

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11253 PR (8.2.x): https://github.com/appcelerator/titanium_mobile/pull/11254
  2. Hans Knöchel 2019-10-02

    We have many candidates for this issue and will try it out immediately, thank you!
  3. Lokesh Choudhary 2019-10-03

    FR Passed. Waiting for jenkins to merge.
  4. Christopher Williams 2019-10-08

    Merged to master and 8_2_X
  5. Sohail Saddique 2019-10-10

    Fix verified with build: 8.2.1.v20191009074714 App no longer hangs upon long press. Ticket closed.

JSON Source