Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the logbox window explicitly. New behavior in iOS SDK appears to… #32435

Closed
wants to merge 1 commit into from

Conversation

paddlefish
Copy link
Contributor

@paddlefish paddlefish commented Oct 18, 2021

Summary

Fixes #32434: RCTLogBox window is orphaned, covering entire screen.

After this change, the logbox window once again is removed from the screen.

Changelog

Some third-party SDKs may hold references to created UIWindow, UIViewController, or UIView objects. Doing so means that the current code's hide method that releases the reference to the UIWindow in LogBox will not cause the window to be dealloc'd, and thus instead it will remain on the screen. This change explicitly hides the LogBox window when the reference is released, so that even if some other SDK holds onto the window it will still be taken off the screen.

[iOS] [Fixed] - 32434

Test Plan

  1. Use console.warn to generate a yellow warning message in log box.  Also install a third-party SDK that holds onto a reference to UIWindow -- for example the Facebook SDK, the Data Dog SDK, or any number of other SDKs that use `swizzling` to intercept calls like `viewDidAppear:`.
    
  2. click the log
    
  3. tap "dismiss"
    
  4. try to tap anywhere
    
  5. Use Xcode view debugger to inspect the UI state

Expected

The app still responds to the touch.
In Xcode, there is not an extra UIWindow covering the screen

@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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Oct 18, 2021
@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels Oct 18, 2021
@pull-bot
Copy link

PR build artifact for 1d47f16 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,310,244 +0
android hermes armeabi-v7a 7,874,312 +0
android hermes x86 8,677,251 +0
android hermes x86_64 8,636,466 +0
android jsc arm64-v8a 9,812,535 +0
android jsc armeabi-v7a 8,773,418 +0
android jsc x86 9,761,393 +0
android jsc x86_64 10,362,338 +0

Base commit: 0c07500
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 63f66fc
Branch: main

@charlesbdudley
Copy link
Contributor

I'm having difficulty reproducing this issue, can you provide a snack or an example project please?

@paddlefish
Copy link
Contributor Author

@charlesbdudley I created a new project with the same iOS SDK and was also unable to reproduce this. I spent a while in my real app using Instruments to see if I could figure out where the retain cycle is coming from. I have several third party SDKs installed. As is typical with "no code" marketing SDKs, these SDKs use swizzling to insert their hooks all over the place. It's entirely possible that one of them is holding on to the "keyWindow" for some reason. I've located several places these sdks make calls to get all the applications windows, and iterate them.

However, even if that's true, I don't see why the proposed fix for this is a bad thing. Right now the logbox window only closes because it gets dealloc'd. The intention of the hide method is to hide the window; it seems like it should do that even if some other piece of code has a reference to the window. Or a reference to a window's view, or a a windows view controller ... as it is now, it's a house of cards.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Oct 19, 2021
@charlesbdudley
Copy link
Contributor

@paddlefish That makes sense to me! Thanks for digging deeper on this. To avoid confusion for the changelog, do you mind updating the title and description (more of an enhancement now than a bug fix)? Then I'll import it for internal review.

@paddlefish
Copy link
Contributor Author

@charlesbdudley I updated the title and description.

@facebook-github-bot
Copy link
Contributor

@sshic has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@philIip philIip left a comment

Choose a reason for hiding this comment

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

i feel we should think of some way to remove the view from the actual hierarchy, though that is probably the responsibility of whomever decided to retain this window.

i think this is the safest and least invasive way to resolve this edge case, so accepting!

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

@sshic merged this pull request in 72ea0e1.

lunaleaps pushed a commit that referenced this pull request Nov 4, 2021
#32435)

Summary:
Fixes  #32434: RCTLogBox window is orphaned, covering entire screen.

After this change, the logbox window once again is removed from the screen.

## Changelog

Some third-party SDKs may hold references to created UIWindow, UIViewController, or UIView objects. Doing so means that the current code's `hide` method that releases the reference to the UIWindow in LogBox will not cause the window to be dealloc'd, and thus instead it will remain on the screen. This change explicitly hides the LogBox window when the reference is released, so that even if some other SDK holds onto the window it will still be taken off the screen.

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - 32434

Pull Request resolved: #32435

Test Plan:
1.     Use console.warn to generate a yellow warning message in log box.  Also install a third-party SDK that holds onto a reference to UIWindow -- for example the Facebook SDK, the Data Dog SDK, or any number of other SDKs that use `swizzling` to intercept calls like `viewDidAppear:`.
2.     click the log
3.     tap "dismiss"
4.     try to tap anywhere
5. Use Xcode view debugger to inspect the UI state

## Expected

The app still responds to the touch.
In Xcode, there is not an extra UIWindow covering the screen

Reviewed By: philIip

Differential Revision: D31794242

Pulled By: sshic

fbshipit-source-id: 28aa247b3ed3fd60b8e7c2ed7d0606cbf5c42408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Needs: Attention Issues where the author has responded to feedback. Platform: iOS iOS applications. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RCTLogBox window is orphaned, covering entire screen
7 participants