Skip to content

Commit a11d577

Browse files
committed
revert: "perf: reduce amount of layout calls and debounce layouts when needed (#10164)"
This reverts commit 8b721c1.
1 parent 8da1ca9 commit a11d577

File tree

4 files changed

+27
-111
lines changed

4 files changed

+27
-111
lines changed

apps/automated/src/test-runner.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,19 @@ allTests['STACKLAYOUT'] = stackLayoutTests;
138138
import * as flexBoxLayoutTests from './ui/layouts/flexbox-layout-tests';
139139
allTests['FLEXBOXLAYOUT'] = flexBoxLayoutTests;
140140

141-
// import * as safeAreaLayoutTests from './ui/layouts/safe-area-tests';
142-
// import * as safeAreaListViewtTests from './ui/list-view/list-view-safe-area-tests';
143-
// import * as scrollViewSafeAreaTests from './ui/scroll-view/scroll-view-safe-area-tests';
144-
// import * as repeaterSafeAreaTests from './ui/repeater/repeater-safe-area-tests';
145-
// import * as webViewSafeAreaTests from './ui/web-view/web-view-safe-area-tests';
146-
147-
// if (isIOS && Utils.ios.MajorVersion > 10) {
148-
// allTests['SAFEAREALAYOUT'] = safeAreaLayoutTests;
149-
// allTests['SAFEAREA-LISTVIEW'] = safeAreaListViewtTests;
150-
// allTests['SAFEAREA-SCROLL-VIEW'] = scrollViewSafeAreaTests;
151-
// allTests['SAFEAREA-REPEATER'] = repeaterSafeAreaTests;
152-
// allTests['SAFEAREA-WEBVIEW'] = webViewSafeAreaTests;
153-
// }
141+
import * as safeAreaLayoutTests from './ui/layouts/safe-area-tests';
142+
import * as safeAreaListViewtTests from './ui/list-view/list-view-safe-area-tests';
143+
import * as scrollViewSafeAreaTests from './ui/scroll-view/scroll-view-safe-area-tests';
144+
import * as repeaterSafeAreaTests from './ui/repeater/repeater-safe-area-tests';
145+
import * as webViewSafeAreaTests from './ui/web-view/web-view-safe-area-tests';
146+
147+
if (isIOS && Utils.ios.MajorVersion > 10) {
148+
allTests['SAFEAREALAYOUT'] = safeAreaLayoutTests;
149+
allTests['SAFEAREA-LISTVIEW'] = safeAreaListViewtTests;
150+
allTests['SAFEAREA-SCROLL-VIEW'] = scrollViewSafeAreaTests;
151+
allTests['SAFEAREA-REPEATER'] = repeaterSafeAreaTests;
152+
allTests['SAFEAREA-WEBVIEW'] = webViewSafeAreaTests;
153+
}
154154

155155
import * as rootViewsCssClassesTests from './ui/styling/root-views-css-classes-tests';
156156
allTests['ROOT-VIEWS-CSS-CLASSES'] = rootViewsCssClassesTests;
@@ -278,8 +278,8 @@ allTests['TAB-VIEW-ROOT'] = tabViewRootTests;
278278
import * as resetRootViewTests from './ui/root-view/reset-root-view-tests';
279279
allTests['RESET-ROOT-VIEW'] = resetRootViewTests;
280280

281-
// import * as rootViewTests from './ui/root-view/root-view-tests';
282-
// allTests['ROOT-VIEW'] = rootViewTests;
281+
import * as rootViewTests from './ui/root-view/root-view-tests';
282+
allTests['ROOT-VIEW'] = rootViewTests;
283283

284284
import * as utilsTests from './utils/utils-tests';
285285
allTests['UTILS'] = utilsTests;

packages/core/ui/core/view/index.ios.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export class View extends ViewCommon implements ViewDefinition {
211211
const boundsOrigin = nativeView.bounds.origin;
212212
const boundsFrame = adjustedFrame || frame;
213213
nativeView.bounds = CGRectMake(boundsOrigin.x, boundsOrigin.y, boundsFrame.size.width, boundsFrame.size.height);
214+
nativeView.layoutIfNeeded();
214215

215216
this._raiseLayoutChangedEvent();
216217
this._isLaidOut = true;
@@ -888,9 +889,6 @@ export class View extends ViewCommon implements ViewDefinition {
888889
}
889890

890891
_setNativeClipToBounds() {
891-
if (!this.nativeViewProtected) {
892-
return;
893-
}
894892
const backgroundInternal = this.style.backgroundInternal;
895893
this.nativeViewProtected.clipsToBounds = (this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius()) && !backgroundInternal.hasBoxShadow();
896894
}

packages/core/ui/core/view/view-helper/index.ios.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,9 @@ const majorVersion = iOSNativeHelper.MajorVersion;
1414
class UILayoutViewController extends UIViewController {
1515
public owner: WeakRef<View>;
1616

17-
private _isRunningLayout: number;
18-
private get isRunningLayout() {
19-
return this._isRunningLayout !== 0;
20-
}
21-
private startRunningLayout() {
22-
this._isRunningLayout++;
23-
}
24-
private finishRunningLayout() {
25-
this._isRunningLayout--;
26-
this.clearScheduledLayout();
27-
}
28-
private runLayout(cb: () => void) {
29-
try {
30-
this.startRunningLayout();
31-
cb();
32-
} finally {
33-
this.finishRunningLayout();
34-
}
35-
}
36-
37-
layoutTimer: number;
38-
39-
private clearScheduledLayout() {
40-
if (this.layoutTimer) {
41-
clearTimeout(this.layoutTimer);
42-
this.layoutTimer = null;
43-
}
44-
}
45-
46-
private scheduleLayout() {
47-
if (this.layoutTimer) {
48-
return;
49-
}
50-
setTimeout(() => {
51-
this.layoutTimer = null;
52-
if (!this.isRunningLayout) {
53-
this.runLayout(() => this.layoutOwner());
54-
}
55-
});
56-
}
57-
5817
public static initWithOwner(owner: WeakRef<View>): UILayoutViewController {
5918
const controller = <UILayoutViewController>UILayoutViewController.new();
6019
controller.owner = owner;
61-
controller._isRunningLayout = 0;
6220

6321
return controller;
6422
}
@@ -71,11 +29,6 @@ class UILayoutViewController extends UIViewController {
7129
this.extendedLayoutIncludesOpaqueBars = true;
7230
}
7331

74-
public viewSafeAreaInsetsDidChange(): void {
75-
super.viewSafeAreaInsetsDidChange();
76-
this.scheduleLayout();
77-
}
78-
7932
public viewWillLayoutSubviews(): void {
8033
super.viewWillLayoutSubviews();
8134
const owner = this.owner?.deref();
@@ -85,20 +38,8 @@ class UILayoutViewController extends UIViewController {
8538
}
8639

8740
public viewDidLayoutSubviews(): void {
88-
this.startRunningLayout();
8941
super.viewDidLayoutSubviews();
90-
this.layoutOwner();
91-
this.finishRunningLayout();
92-
}
93-
layoutOwner(force = false) {
9442
const owner = this.owner?.deref();
95-
if (!force && !!owner.nativeViewProtected?.layer.needsLayout?.()) {
96-
// we skip layout if the view is not yet laid out yet
97-
// this usually means that viewDidLayoutSubviews will be called again
98-
// so doing a layout pass now will layout with the wrong parameters
99-
return;
100-
}
101-
10243
if (owner) {
10344
if (majorVersion >= 11) {
10445
// Handle nested UILayoutViewController safe area application.

packages/core/ui/page/index.ios.ts

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class UIViewControllerImpl extends UIViewController {
7474

7575
public isBackstackSkipped: boolean;
7676
public isBackstackCleared: boolean;
77+
private didFirstLayout: boolean;
7778
// this is initialized in initWithOwner since the constructor doesn't run on native classes
7879
private _isRunningLayout: number;
7980
private get isRunningLayout() {
@@ -84,7 +85,7 @@ class UIViewControllerImpl extends UIViewController {
8485
}
8586
private finishRunningLayout() {
8687
this._isRunningLayout--;
87-
this.clearScheduledLayout();
88+
this.didFirstLayout = true;
8889
}
8990
private runLayout(cb: () => void) {
9091
try {
@@ -95,31 +96,11 @@ class UIViewControllerImpl extends UIViewController {
9596
}
9697
}
9798

98-
layoutTimer: number;
99-
100-
private clearScheduledLayout() {
101-
if (this.layoutTimer) {
102-
clearTimeout(this.layoutTimer);
103-
this.layoutTimer = null;
104-
}
105-
}
106-
107-
private scheduleLayout() {
108-
if (this.layoutTimer) {
109-
return;
110-
}
111-
setTimeout(() => {
112-
this.layoutTimer = null;
113-
if (!this.isRunningLayout) {
114-
this.runLayout(() => this.layoutOwner());
115-
}
116-
});
117-
}
118-
11999
public static initWithOwner(owner: WeakRef<Page>): UIViewControllerImpl {
120100
const controller = <UIViewControllerImpl>UIViewControllerImpl.new();
121101
controller._owner = owner;
122102
controller._isRunningLayout = 0;
103+
controller.didFirstLayout = false;
123104

124105
return controller;
125106
}
@@ -300,24 +281,19 @@ class UIViewControllerImpl extends UIViewController {
300281

301282
public viewSafeAreaInsetsDidChange(): void {
302283
super.viewSafeAreaInsetsDidChange();
303-
this.scheduleLayout();
284+
if (this.isRunningLayout || !this.didFirstLayout) {
285+
return;
286+
}
287+
const owner = this._owner?.deref();
288+
if (owner) {
289+
this.runLayout(() => IOSHelper.layoutView(this, owner));
290+
}
304291
}
305292

306293
public viewDidLayoutSubviews(): void {
307294
this.startRunningLayout();
308295
super.viewDidLayoutSubviews();
309-
this.layoutOwner();
310-
this.finishRunningLayout();
311-
}
312-
313-
layoutOwner(force = false) {
314296
const owner = this._owner?.deref();
315-
if (!force && !!owner.nativeViewProtected?.layer.needsLayout?.()) {
316-
// we skip layout if the view is not yet laid out yet
317-
// this usually means that viewDidLayoutSubviews will be called again
318-
// so doing a layout pass now will layout with the wrong parameters
319-
return;
320-
}
321297
if (owner) {
322298
// layout(owner.actionBar)
323299
// layout(owner.content)
@@ -369,6 +345,7 @@ class UIViewControllerImpl extends UIViewController {
369345

370346
IOSHelper.layoutView(this, owner);
371347
}
348+
this.finishRunningLayout();
372349
}
373350

374351
// Mind implementation for other controllerss

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy