-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
insets.top switching to 0 during iPad orientation change #485
Comments
Does it happen with just this library - or is it only with react navigation? |
@jacobp100 import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
export default function App() {
return (
<SafeAreaProvider>
<Kid />
</SafeAreaProvider>
);
}
function Kid() {
const insets = useSafeAreaInsets();
console.log({ insets });
return null;
}
As all iOS apps with a blurred header put |
For the lag, try setting I'm not too sure why you get those insets - but presumably, iOS is giving them. If you're comfortable with Xcode, it would useful to know if those are coming from UIKit, and how far apart they are. I know react native can coalesce some events that are really close (like scroll events) - it's opt-in, but it might be a good workaround |
I've replaced - (void)safeAreaInsetsDidChange
{
[self invalidateSafeAreaInsets];
} by - (void) viewSafeAreaInsetsDidChange
{
[self invalidateSafeAreaInsets];
} in RNCSafeAeraProvider.mm and that does the trick of not switching to 0 during orientation change. I've also debugged the app more, and it turns out I have a // useBottomTabBarOffset in RN-bottom-tabs
const getPaddingBottom = (insets: EdgeInsets) =>
Math.max(insets.bottom - Platform.select({ ios: 4, default: 0 }), 0); |
lol this solves the problem if (safeAreaInsets.top < 1.0 || safeAreaInsets.bottom < 1.0 || ( _initialInsetsSent &&
UIEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale()) &&
CGRectEqualToRect(frame, _currentFrame))) {
return;
} Maybe this should be improved // This gets called before the view size is set by react-native so
// make sure to wait so we don't set wrong insets to JS.
if (CGSizeEqualToSize(self.frame.size, CGSizeZero)) {
return;
} |
You want to look in I think the check proposed isn't safe, because the insets can be zero in some circumstances. It would be useful to get information about the timing between the two events. Are they almost instantly after each other? |
@jacobp100 code I was referring to is indeed in |
Is that called? That's a UIViewContoller method - and this is a UIView |
|
@jacobp100 What would be a good way to batch |
Look in the main source:- |
On iPad,
insets.top
changes during an orientation change from X to 0 and back to X, causing the app to re-render and recalculate layouts back and forth.This only happens when going from landscape to portrait.
I've opened a related issue on RN-navigation: react-navigation/react-navigation#11915
EDIT:
insets.top changes from landscape to portrait to 0
insets.bottom changes from portrait to landscape to 0
The text was updated successfully, but these errors were encountered: