Skip to content

perf(apple,ios,engine): hint 120Hz ProMotion frame rates, skip FollowBounds reads, release nav symbols, log max frame - #2716

Merged
oneo-me merged 2 commits into
nsgo-dev:mainfrom
Heyana:perf/ios-nav-promotion-and-hotpaths
Nov 29, 2026
Merged

oneo-me merged 2 commits into
nsgo-dev:mainfrom
Heyana:perf/ios-nav-promotion-and-hotpaths

Conversation

@Heyana

@Heyana Heyana commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Scoped down from the original PR per review feedback to keep only the focused, non-controversial changes on top of main:

  • 120Hz ProMotion CAAnimation frame rate hints (internal/platform/apple/layer.go, image.go, framerate_test.go, internal/platform/ios/nav.go):
    • Added apple.SetAnimationFrameRate(anim, maxFPS) setting CAFrameRateRange (Minimum: min(80, maxFPS), Maximum: maxFPS, Preferred: maxFPS) on route slide animations, modal entrance animations, and layer transitions.
  • Early return in FollowBounds (internal/platform/apple/decor.go):
    • Return early before reading CGRect bounds when a layer has neither decor nor ring.
  • Release retained nav bar symbols on delete (internal/platform/ios/ios.go):
    • Release b.symbols alongside b.system when deleting a screen view.
  • Include worst-case frame spike in -fps logs (internal/engine/perf.go):
    • Include max <Frame.Max> alongside frame mean and p95 in PerfSnapshot.String().
  • Added changelog.d/ios-promotion-and-frame-stats.md.

Split out / dropped from this PR

  • Dropped the superseded core/ VisibilityHidden changes (already covered by node.covered in fix(core): keep the layout of a screen another covers #2601) and rebased onto main.
  • Dropped the styleLayerBound diffing change that caused border/background regressions with decor.
  • Split the iOS UINavigationBar caching + purego hot paths (with field-wise driver.Font comparison and shared libobjc typed objc_msgSend) and the delaysContentTouches discussion into separate focused PRs.

Verification

  • gofmt clean
  • go run ./tools/changelog check — passed
  • go tool nsgo check -target ios,macos -jobs 4 — passed (macos_x64, macos_arm64, ios)
  • go test ./internal/engine/... ./internal/platform/apple/... — passed

@oneo-me oneo-me left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for digging into iOS navigation performance — the profiling is useful. This can't merge as is, though:

Blocking

  1. The iOS target doesn't build. go tool nsgo check -target ios fails:

    internal/platform/ios/nav.go:338:3: invalid operation: a.TitleFont != b.TitleFont (struct containing map[string]float32 cannot be compared)
    

    Same at nav.go:339 and twice at nav.go:359. driver.Font holds a map, so it needs a field-wise comparison. CI skipped Build and vet (Apple) because Go formatting failed first. Please run go tool nsgo check -target ios,macos rather than go test on the host.

  2. Diffing in styleLayerBound loses borders and backgrounds (internal/platform/apple/layer.go:90-112, macOS and iOS). The old code reset the layer's background, corner radius and border width on every call before applyDecor overrode them, and decor clears them when it draws a shape or a dashed border (decor.go:439, 723, 727). With the diff, a cleared value is never restored. A local test confirms it: a layer styled BorderWidth: 2, BorderStyle: BorderDashed, then restyled with BorderSolid, ends with borderWidth 0 instead of 2. The same test passes on main. The background is lost the same way when a shaped style goes back to plain corners.

  3. The core change is superseded and conflicts. main already keeps a covered screen's layout through node.covered (197e075, #2601). The VisibilityHidden change in core/tree.go, core/commit.go and core/keys.go duplicates it and conflicts in core/tree.go and core/nav_test.go. Please drop it and rebase onto main.

  4. gofmt: internal/platform/apple/layer.go (the var block at lines 38-40).

To discuss

  • setDelaysContentTouches: false (ios/behavior.go:128) departs from UIKit's default: rows and buttons in a scroll view highlight as soon as they're touched, then flash off when the drag starts. A maintainer should decide whether we want that.
  • create() no longer calls directTree for standalone LTR views and leaves them to UIView.appearance, and direct() drops setNeedsLayout. Please confirm direction_native_test passes on a simulator with an RTL system language.
  • sendSetFrame dlopens libobjc a second time. A typed objc_msgSend belongs in internal/platform/apple, like msgSendFloat64.
  • Missing a changelog.d/ fragment.
  • Please split this into focused PRs (frame rate hints, touch delay, nav bar caching, purego hot paths, perf log). The smaller pieces look fine: max in the -fps line, the early return in FollowBounds, SetAnimationFrameRate and releasing b.symbols on delete. They'd be easy to land on their own.

Ran: go tool nsgo check -target ios,macos -jobs 4 (iOS fails, macOS passes) and go tool nsgo test ./core/... ./internal/engine/... ./internal/platform/apple/... (1262 passed). I couldn't reproduce the device benchmarks here.

🤖 Claude Opus 5.5

@Heyana
Heyana force-pushed the perf/ios-nav-promotion-and-hotpaths branch from cc32123 to 3482363 Compare November 29, 2026 03:05
@Heyana Heyana changed the title perf(ios,apple,core): unlock 120Hz ProMotion transitions and cut route push/pop overhead perf(apple,ios,engine): hint 120Hz ProMotion frame rates, skip FollowBounds reads, release nav symbols, log max frame Nov 29, 2026
@github-actions github-actions Bot added size/S documentation Improvements or additions to documentation size/M and removed size/M size/S labels Nov 29, 2026
@Heyana

Heyana commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review! I've cleaned up and split #2716 as suggested:

Also left direction.go untouched for now to avoid any RTL regressions.

@Heyana
Heyana force-pushed the perf/ios-nav-promotion-and-hotpaths branch from 3482363 to 7b90eed Compare November 29, 2026 04:48
@github-actions github-actions Bot added size/S and removed size/M labels Nov 29, 2026
@oneo-me

oneo-me commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Heyana — I pushed 8779ba6 on top of your commit to finish the frame rate hints:

  • Style transitions (apple/layer.go) and modal entrances (AnimateIn) passed 0, which became a fixed 120 Hz and could cap them on 144 or 240 Hz external displays. They now ask for the highest rate of the screen the view is on (apple.ScreenRate); with no known screen they leave the system's choice. AnimateIn takes the rate: macOS passes apple.ScreenRate(v.native), iOS s.screenRate().
  • The range lives in one place, apple.FrameRateRange (at least 80 Hz up to the screen's highest), which the macOS display link's frameRateRange now uses too.
  • framerate_test.go covers 60, 120 and 240 Hz ranges, rate 0 keeping the default, and ScreenRate without a window.
  • The changelog fragment drops the internal FollowBounds change and describes the rate as the screen's highest.

Ran: go tool nsgo check -target ios,macos -jobs 4 → 0; go tool nsgo test ./internal/engine/... ./internal/platform/apple/... ./internal/platform/ios/... ./internal/platform/macos/... → 488 passed, 1 failed: TestChildWindowFollowsParent (AppKit did not minimize the parent), which passes when run alone and is unrelated. Not measured on a ProMotion device or high-refresh display.

🤖 Claude Opus 5.5

@github-actions

Copy link
Copy Markdown

This pull request has no valid Local CI declaration for its head commit, so a maintainer audits it before merging:

  • the body has no <!-- local-ci --> block under ## Verification

Run the checks on the head commit, fill the block in the template, then push or edit the body: this label and comment update on their own.

@oneo-me
oneo-me enabled auto-merge (rebase) November 29, 2026 11:39
Heyana and others added 2 commits November 29, 2026 20:40
Style transitions and modal entrances asked for 120 Hz whatever the
screen, capping them on faster external displays. Ask for the screen's
highest rate instead, leave the system's choice when it is unknown, and
share the range with the macOS display link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneo-me
oneo-me force-pushed the perf/ios-nav-promotion-and-hotpaths branch from 8779ba6 to 5cb16e6 Compare November 29, 2026 12:43
@oneo-me
oneo-me merged commit 1f9bcce into nsgo-dev:main Nov 29, 2026
44 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants