Skip to content

perf(ios,apple): cache UINavigationBar styling and register objc_msgSend once for hot paths - #2747

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

oneo-me merged 2 commits into
nsgo-dev:mainfrom
Heyana:perf/ios-navbar-cache-and-purego-hotpaths

Conversation

@Heyana

@Heyana Heyana commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Split out from #2716 per review feedback.

  • iOS UINavigationBar caching (internal/platform/ios/nav.go):
    • Reuse a shared default UINavigationBarAppearance and restyle a bar only when its header's style or collapsed state changes (barStyleChanged, with field-wise fontEqual / fontIsZero as driver.Font holds maps).
    • Measure the bar with sizeThatFits: on every header change and when its width changes, but not again on a frame update at the same width.
    • Initialize b.reported to s.headers[0] / [1] on bar creation, the height core already lays a new screen out with, so a pushed screen dispatches EventScreenHeader only when UIKit's height differs.
    • Still give the bar and the views its items and title view make the app's direction on every header change, as an embedded surface sets no appearance proxy.
  • objc_msgSend hot paths (internal/platform/apple, internal/platform/ios/ios.go, media.go):
    • Register a typed objc_msgSend for setFrame: once in internal/platform/apple, beside msgSendFloat64 on the same libobjc handle, as apple.MsgRect, instead of objc.Send registering one on every call.
    • Use apple.Msg (purego.SyscallN, no boxing into any) on the create, insert, hidden and layer paths.
  • Leaves out the styleLayerBound diffing, which lost decor borders and backgrounds, and direction.go.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None

Verification

  • head: 80575ddb3
  • base: 3947e4685
  • commands:
    • go tool nsgo check -target ios,macos -jobs 8 → 0
    • go tool nsgo test ./internal/platform/apple/... ./internal/platform/ios/... ./core/... → 0
  • result: pass
  • not covered: the iOS simulator and devices (the bar's height after a title view or items change, and RTL), tvOS, the Android emulator, Windows, Linux and the browser jobs; no benchmark of the gain

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

🤖 Generated with Claude Code

🤖 Claude Opus 5.5

@oneo-me
oneo-me force-pushed the perf/ios-navbar-cache-and-purego-hotpaths branch from 7e3d2eb to 80575dd Compare November 29, 2026 11:35
@oneo-me oneo-me changed the title perf(ios,apple): cache UINavigationBar styling and use reflection-free purego hot paths perf(ios,apple): cache UINavigationBar styling and register objc_msgSend once for hot paths Nov 29, 2026
@github-actions github-actions Bot added local-ci-pass The head commit declares that its local checks passed and removed local-ci-skipped labels Nov 29, 2026
@oneo-me
oneo-me enabled auto-merge (rebase) November 29, 2026 11:39
@oneo-me
oneo-me merged commit 23f4567 into nsgo-dev:main Nov 29, 2026
49 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation iOS local-ci-pass The head commit declares that its local checks passed macOS size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants