Repository navigation
Use displayScale instead of UIScreen.main - #112
Merged
Merged
Conversation
brynbodayle
approved these changes
Aug 22, 2022
pblazej
added a commit
to webrtc-sdk/webrtc
that referenced
this pull request
May 11, 2026
Drop `[UIScreen mainScreen] / [NSScreen mainScreen]` from `currentScaleFactor`. Still requires some testing, especially in multiscreen scenarios. ### References - [livekit/client-sdk-swift#998](livekit/client-sdk-swift#998) — App Store rejection on iOS 26 citing deprecated UIKit APIs in `LiveKitWebRTC.framework`. - [Apple Developer Forums — `UITraitCollection.displayScale` is the preferred replacement](https://developer.apple.com/forums/thread/733516) (Apple Frameworks Engineer). - [Apple — `UITraitCollection.displayScale`](https://developer.apple.com/documentation/uikit/uitraitcollection/1623519-displayscale) - [Apple Metal Best Practices: Native Screen Scale](https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/MTLBestPracticesGuide/NativeScreenScale.html) — future TODO to switch to `nativeScale` for drawable sizing. Prior art in other SDKs: - [airbnb/MagazineLayout#112](airbnb/MagazineLayout#112) — replaced `UIScreen.main` with `traitCollection.displayScale` directly. - [jellyfin/Swiftfin#1809](jellyfin/Swiftfin#1809) — same migration. - [flutter/flutter#162785](flutter/flutter#162785) — chose `view.window.windowScene.screen.scale`, [reverted in #166080](flutter/flutter#166080) after a downstream `scale == 0` crash (informed the `MAX(scale, 1.0)` safety net here). - [react-native-community#493](react-native-community/discussions-and-proposals#493) — community discussion of the same migration. --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
cloudwebrtc
pushed a commit
to webrtc-sdk/webrtc
that referenced
this pull request
Jul 16, 2026
Drop `[UIScreen mainScreen] / [NSScreen mainScreen]` from `currentScaleFactor`. Still requires some testing, especially in multiscreen scenarios. ### References - [livekit/client-sdk-swift#998](livekit/client-sdk-swift#998) — App Store rejection on iOS 26 citing deprecated UIKit APIs in `LiveKitWebRTC.framework`. - [Apple Developer Forums — `UITraitCollection.displayScale` is the preferred replacement](https://developer.apple.com/forums/thread/733516) (Apple Frameworks Engineer). - [Apple — `UITraitCollection.displayScale`](https://developer.apple.com/documentation/uikit/uitraitcollection/1623519-displayscale) - [Apple Metal Best Practices: Native Screen Scale](https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/MTLBestPracticesGuide/NativeScreenScale.html) — future TODO to switch to `nativeScale` for drawable sizing. Prior art in other SDKs: - [airbnb/MagazineLayout#112](airbnb/MagazineLayout#112) — replaced `UIScreen.main` with `traitCollection.displayScale` directly. - [jellyfin/Swiftfin#1809](jellyfin/Swiftfin#1809) — same migration. - [flutter/flutter#162785](flutter/flutter#162785) — chose `view.window.windowScene.screen.scale`, [reverted in #166080](flutter/flutter#166080) after a downstream `scale == 0` crash (informed the `MAX(scale, 1.0)` safety net here). - [react-native-community#493](react-native-community/discussions-and-proposals#493) — community discussion of the same migration. --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
UIScreen.mainis being deprecated in iOS 16. We should be able to just use the trait collection'sdisplayScaleproperty. All seems to work correctly in my testing.Related Issue
N/A
Motivation and Context
Adopting latest APIs.
How Has This Been Tested
Example app.
Types of changes
Checklist