Skip to content

Avoid calling keyWindow on any UIScene#46832

Closed
cipolleschi wants to merge 1 commit into
facebook:mainfrom
cipolleschi:export-D63890980
Closed

Avoid calling keyWindow on any UIScene#46832
cipolleschi wants to merge 1 commit into
facebook:mainfrom
cipolleschi:export-D63890980

Conversation

@cipolleschi
Copy link
Copy Markdown
Contributor

Summary:
After bumping to minIOSVersion 15.1, we refactored the code to remove some check.
In the refactoring, we changed how the keyWindow is returned and now we are unsafely casting UIScene to UIWindowScene.

We have some internal apps that use UIScene that are not UIWindowScene and the change is causing them to crash.

This change fixes the crash by checking whether the selector is available in the UIScene and casting it only in that case.
Otherwise we return nil, the same behavior we used to have before the refactor.

Changelog

[iOS][Fixed] - Cast the UIScene to UIWindowScene only if the scene respond to the selector

Differential Revision: D63890980

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63890980

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported p: Facebook Partner: Facebook Partner labels Oct 4, 2024
Copy link
Copy Markdown
Contributor

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

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

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63890980

Summary:

After bumping to minIOSVersion 15.1, we refactored the code to remove some check.
In the refactoring, we changed how the `keyWindow` is returned and now we are unsafely casting `UIScene` to `UIWindowScene`.

We have some internal apps that use `UIScene` that are not `UIWindowScene` and the change is causing them to crash.

This change fixes the crash by checking whether the selector is available in the UIScene and casting it only in that case.
Otherwise we return `nil`, the same behavior we used to have before the refactor.

## Changelog
[iOS][Fixed] - Cast the UIScene to UIWindowScene only if the scene respond to the selector

Reviewed By: javache

Differential Revision: D63890980
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63890980

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Oct 4, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in fdee0eb.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @cipolleschi in fdee0eb

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants