[TIMOB-27434] Android: Re-layout of deeply nested views can cause performance issues as of 7.5.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-10-10T15:16:41.000+0000 |
Affected Version/s | Release 7.5.0 |
Fix Version/s | Release 8.2.1 |
Components | Android |
Labels | android, engSchedule, regression, view |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2019-10-02T02:10:44.000+0000 |
Updated | 2020-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:*
Tap and hold on the text within the
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.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/11253 PR (8.2.x): https://github.com/appcelerator/titanium_mobile/pull/11254
We have many candidates for this issue and will try it out immediately, thank you!
FR Passed. Waiting for jenkins to merge.
Merged to master and 8_2_X
Fix verified with build: 8.2.1.v20191009074714 App no longer hangs upon long press. Ticket closed.