-
Notifications
You must be signed in to change notification settings - Fork 20
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
prevent from publishing dimensions change event when app changes state #11
Conversation
…ent when it doesn't apply
I see that PR can be improved in the following ways.
|
@parasharrajat I added the videos of me reproducing the issue and testing this with the fix applied. Had to upload to youtube due to size constrains here on Github.
Please let me know if you believe anything else has to be imoproved/corrected. Thanks. |
I will test this today. |
Hi @parasharrajat any news on this one? |
On my list. Sorry for the delay. I broke my Mac past week so things got piled up. |
Existing issues about this bug we are trying to solve. Please search RN codebase and link any whatever looks the same. In case there are none, create a new one which we can refer to while submitting the PR to RN. |
@parasharrajat I updated the original post. I added the facebook#29290 which was mentioned in the original Expensify/App#2727. |
I will start reviewing this in few minutes. Code looks fine to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your test cases. But you didn't mention test process. How can a person test these code changes on E/App? Please add this detail.
Also, add steps to test your changes in standard testing example app of RN.
React/CoreModules/RCTDeviceInfo.mm
Outdated
if ((((UIInterfaceOrientationIsPortrait(_currentInterfaceOrientation) && | ||
!UIInterfaceOrientationIsPortrait(nextOrientation)) || | ||
(UIInterfaceOrientationIsLandscape(_currentInterfaceOrientation) && | ||
!UIInterfaceOrientationIsLandscape(nextOrientation))) { | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
[[_moduleRegistry moduleForName:"EventDispatcher"] | ||
sendDeviceEventWithName:@"didUpdateDimensions" | ||
body:RCTExportedDimensions(_moduleRegistry, _bridge)]; | ||
#pragma clang diagnostic pop | ||
!UIInterfaceOrientationIsLandscape(nextOrientation)) || (isRunningInFullScreen != _isFullscreen || !isRunningInFullScreen))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's break this if condition in more readable form. Also, improve the comment to indicate every case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, in b0c3bc7
|
||
_currentInterfaceDimensions = nextInterfaceDimensions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we moving these inside the if blocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment in code, but that's moved inside so that we make sure that the state between JS and Obj-C is synced. Meaning we only update the 'Native' state when it's published to JS.
Why? |
So that in case of this event we also have the extended handler, which considers the fullscreen as well as active state. |
Updated |
Sorry, ignore this. I was doing totally different thing. 🗣️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am running final tests. Looking good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
cc: @iwiznia Please review this PR.
Co-authored-by: Rajat Parashar <[email protected]>
Co-authored-by: Rajat Parashar <[email protected]>
React/CoreModules/RCTDeviceInfo.mm
Outdated
|
||
|
||
BOOL isActive = appState == UIApplicationStateActive; | ||
BOOL isChangingFullscreen = (isRunningInFullScreen != _isFullscreen || !isRunningInFullScreen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a weird condition, and the name does not seem to match the condition
If we are keeping the condition logic, I think we need a comment to explain why this is not simply
BOOL isChangingFullscreen = isRunningInFullScreen != _isFullscreen;
Also the condition logic could be simplified to
BOOL isChangingFullscreen = !isRunningInFullScreen || !_isFullscreen;
And again I'm not entirely sure that condition makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition indeed can be shortened to what you suggested, good catch. Thanks.
The condition is needed and called this way because it catches two scenarios:
a) Simple resize when the app isn't in the fullscreen mode right now - the !isRunningInFullScreen
b) Resize when the app gets from slide over mode to fullscreen - isRunningInFullScreen != _isFullscreen
Anyway, I commented this line with the above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question about one of the conditions about isChangingFullscreen
The rest seems good
… name, add more comments describing it
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🎀 👀 🎀 C+ reviewed
@parasharrajat is there any action pending on me to get this one merged? Or shall we simply wait for inputs from @iwiznia. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This one. |
Summary
An issue raised in Expensify/App#2727 has to be fixed in react native core. This impacts IOS only.
React Native issue: facebook#29290
Changelog
a) The body of the _interfaceOrientationDidChange:
Here we make sure we run this function when the app is in active and also it was switching to fullscreeen or is not running in fullscreen.
b) _interfaceFrameDidChange
Here we make sure we run it when the app is in active state.
c) Add the _isFullscreen variable to hold the previous state for multitasking view.
d) We need to make sure to run the interfaceOrientationDidChange instead of interfaceFrameDidChange when the UIApplicationDidBecomeActiveNotification occurs.
Test Plan
Test Preparation
this.onDimensionChange = _.debounce(this.onDimensionChange.bind(this), 100);
to
this.onDimensionChange = this.onDimensionChange.bind(this);
iPad Mini tests:
Reproduction + Fix test video (Test 1): https://youtu.be/jyzoNHLYHPo
Reproduction + Fix test video (Test 2): https://youtu.be/CLimE-Fba-g
Test 1:
Test 2:
iPad Pro tests:
Reproduction + Fix test video (Test 3, Test 4): https://youtu.be/EJkUUQCiLRg
iPad mini test 1 applies.
Scenario 2 does not as the screen is too wide in both orientations and iPad pro shows sidebar always.
Test 3:
Test 4:
iPhone:
Non reg with and without the fix video: https://youtu.be/kuv9in8vtbk
Please perform standard smoke tests on transformation changes.