From 0d5184328e3e413cdf4b74d6af007331e032a177 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sat, 19 Jul 2025 14:14:33 +0300 Subject: [PATCH 1/2] ref(core): Improved safe-area background update check --- apps/automated/src/ui/view/view-tests.ios.ts | 2 +- packages/core/ui/core/view/index.ios.ts | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/automated/src/ui/view/view-tests.ios.ts b/apps/automated/src/ui/view/view-tests.ios.ts index 7471c0fdf8..e3e8c28c67 100644 --- a/apps/automated/src/ui/view/view-tests.ios.ts +++ b/apps/automated/src/ui/view/view-tests.ios.ts @@ -77,7 +77,7 @@ export function testBackgroundInternalChangedOnceOnResize() { TKUnit.assertEqual(trackCount(), 1, 'Expected background to be re-applied at most once when the view is laid-out on 0 0 200 200.'); - // Ignore safe area as it may result in re-calculating view frame, thus trigger a size change regardless + // Ignore safe area as it may result in re-calculating view position, invalidating background layout.iosIgnoreSafeArea = true; layout.requestLayout(); diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index 39d3d2f485..c8818df84f 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -106,14 +106,13 @@ export class View extends ViewCommon implements ViewDefinition { @profile public layout(left: number, top: number, right: number, bottom: number, setFrame = true): void { - const result = this._setCurrentLayoutBounds(left, top, right, bottom); - let { sizeChanged } = result; + const { boundsChanged, sizeChanged } = this._setCurrentLayoutBounds(left, top, right, bottom); if (setFrame) { this.layoutNativeView(left, top, right, bottom); } - const needsLayout = result.boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED; + const needsLayout = boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED; if (needsLayout) { let position: Position; @@ -122,11 +121,11 @@ export class View extends ViewCommon implements ViewDefinition { // get the frame and adjust the position, so that onLayout works correctly position = IOSHelper.getPositionFromFrame(this.nativeViewProtected.frame); - if (!sizeChanged) { - // If frame has actually changed, there is the need to update view background and border styles as they depend on native view bounds - // To trigger the needed visual update, mark size as changed + if (this._nativeBackgroundState !== 'invalid') { + // If frame position was updated due to safe area, there is the need to update view background and border styles as they depend on native view bounds + // To trigger the needed visual update, invalidate the background state if (position.left !== left || position.top !== top || position.right !== right || position.bottom !== bottom) { - sizeChanged = true; + this._nativeBackgroundState = 'invalid'; } } } else { From 849e553ae391d8f3859328015d33897d921008f8 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 20 Jul 2025 21:34:19 +0300 Subject: [PATCH 2/2] chore: Removed background state invalidation --- apps/automated/src/ui/view/view-tests.ios.ts | 5 ----- packages/core/ui/core/view/index.ios.ts | 8 -------- packages/core/ui/styling/background.ios.ts | 1 - 3 files changed, 14 deletions(-) diff --git a/apps/automated/src/ui/view/view-tests.ios.ts b/apps/automated/src/ui/view/view-tests.ios.ts index e3e8c28c67..72a61afd08 100644 --- a/apps/automated/src/ui/view/view-tests.ios.ts +++ b/apps/automated/src/ui/view/view-tests.ios.ts @@ -77,16 +77,11 @@ export function testBackgroundInternalChangedOnceOnResize() { TKUnit.assertEqual(trackCount(), 1, 'Expected background to be re-applied at most once when the view is laid-out on 0 0 200 200.'); - // Ignore safe area as it may result in re-calculating view position, invalidating background - layout.iosIgnoreSafeArea = true; - layout.requestLayout(); layout.layout(50, 50, 250, 250); TKUnit.assertEqual(trackCount(), 0, 'Expected background to NOT change when view is laid-out from 0 0 200 200 to 50 50 250 250.'); - layout.iosIgnoreSafeArea = false; - layout.requestLayout(); layout.layout(0, 0, 250, 250); diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index c8818df84f..fe6658dd67 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -120,14 +120,6 @@ export class View extends ViewCommon implements ViewDefinition { // on iOS 11+ it is possible to have a changed layout frame due to safe area insets // get the frame and adjust the position, so that onLayout works correctly position = IOSHelper.getPositionFromFrame(this.nativeViewProtected.frame); - - if (this._nativeBackgroundState !== 'invalid') { - // If frame position was updated due to safe area, there is the need to update view background and border styles as they depend on native view bounds - // To trigger the needed visual update, invalidate the background state - if (position.left !== left || position.top !== top || position.right !== right || position.bottom !== bottom) { - this._nativeBackgroundState = 'invalid'; - } - } } else { position = { left, top, right, bottom }; } diff --git a/packages/core/ui/styling/background.ios.ts b/packages/core/ui/styling/background.ios.ts index 01632991a5..aa869441a7 100644 --- a/packages/core/ui/styling/background.ios.ts +++ b/packages/core/ui/styling/background.ios.ts @@ -9,7 +9,6 @@ import { ImageSource } from '../../image-source'; import type { CSSValue } from '../../css-value/reworkcss-value'; import { parse as cssParse } from '../../css-value/reworkcss-value.js'; import { BoxShadow } from './box-shadow'; -import { Length } from './style-properties'; import { BackgroundClearFlags } from './background-common'; import { ClipPathFunction } from './clip-path-function';