Skip to content

Moving DynamicColor back to struct#2150

Merged
mischreiber merged 2 commits intomicrosoft:mainfrom
mischreiber:DynamicColorStruct
May 7, 2025
Merged

Moving DynamicColor back to struct#2150
mischreiber merged 2 commits intomicrosoft:mainfrom
mischreiber:DynamicColorStruct

Conversation

@mischreiber
Copy link
Copy Markdown
Collaborator

@mischreiber mischreiber commented May 7, 2025

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

We were running into a very rare crash when simultaneously accessing the same Fluent color on multiple threads. There appears to be some cacheing issue when creating a UIColor that wraps a dynamic SwiftUI Color when the resolver is a class instead of a struct.

In the meantime, a quick fix is to change it back to a struct (I don't even remember why it was a class in the first place).

This does do away with Objective-C support for DynamicColor, but that was pretty short lived anyway :)

Binary change

(how is our binary size impacted -- see https://github.com/microsoft/fluentui-apple/wiki/Size-Comparison)

Verification

Verified that we can create 100,000 Fluent colors simultaneously without crashing (before this change, it would crash 100% at that scale).

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@mischreiber mischreiber requested a review from a team as a code owner May 7, 2025 22:15
@mischreiber mischreiber merged commit bc4b017 into microsoft:main May 7, 2025
7 checks passed
@mischreiber mischreiber deleted the DynamicColorStruct branch May 7, 2025 23:04
@mischreiber mischreiber mentioned this pull request Jun 13, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants