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

InteractionManager.runAfterInteractions not running at all! (In Production/Release builds) #8606

Closed
mrousavy opened this issue Jul 18, 2020 · 7 comments

Comments

@mrousavy
Copy link
Sponsor

mrousavy commented Jul 18, 2020

Current Behavior

I am using a lot of InteractionManager.runAfterInteractions(() => ...) calls throughout my project.

For example, I have a feed of multiple posts in my HomeScreen (Tab Navigator) and each post has useEffect and useFocusEffect hooks which call InteractionManager.runAfterInteractions inside the hook to schedule loading extra post data after some animations have completed. "Some animations" = mostly navigation transitions from react-navigation, but since the post items specifically are inside a Tab Navigator, no navigation transitions/animations are run so this should fire almost immediately.

In development/debug build everything works fine, but once I build for production/release, the extra post data never gets loaded, a test Alert.alert(...) I've put in there never gets shown, and my animations will never start, causing my app to be fully stuck.

I have added a GlobalErrorHandler callback to my entry point (App.tsx):

const defaultErrorHandler = ErrorUtils.getGlobalHandler();
ErrorUtils.setGlobalHandler((error, isFatal) => {
	Alert.alert(`Unexpected ${isFatal ? 'fatal error' : 'error'}!`, `Unexpected error occured! ${JSON.stringify(error)}`);
	Logger.logError(isFatal ? 'A fatal, unhandled error occured!' : 'An unhandled error occured!', error);
	if (defaultErrorHandler) defaultErrorHandler(error, isFatal);
});

but this doesn't get called either.

Unfortunately, since this only happens on production/release builds, I'm having a hard time debugging this. I will happily provide any extra information needed.

Extra Details

  • I'm using react-navigation, so this might cause a problem I suppose. My root view is a NavigationContainer, and inside of it, I conditionally render the LoginStackNavigator or the HomeStackNavigator depending if the user is logged in or not.
  • I'm using react-native-screens (because of react-navigation), but I call the enableScreens() function at the top of my entry point (App.tsx):
    import { enableScreens } from 'react-native-screens';
    enableScreens();
  • I'm using react-native-gesture-handler (because of react-navigation), but I import the library at the top of my entry point (App.tsx):
    import 'react-native-gesture-handler';
  • I'm using react-native-vector-icons, but I call loadFont() at the top of my entry point (App.tsx):
    import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
    Icon.loadFont();

Right now, the InteractionManager does not call the callback function at all, causing my app to be "broken". Data is never getting loaded, delayed animations are not getting started, etc.

Expected Behavior

The InteractionManager should call the callback after animations have finished. (Which, on a Tab navigator, should be instantly.)

Debug/Development Build Release/Production Build
Everything working fine, all InteractionManager.runAfterInteraction callbacks inside my useEffect hooks are being called. Everything is broken, InteractionManager.runAfterInteraction callbacks inside my useEffect hooks are not being called, the text for the post is not being loaded (which is inside an InteractionManager.runAfterInteraction callback), and weirdly the react-native-vector-icons are not being displayed. no idea why that's the case, since that has nothing to do with an InteractionManager.runAfterInteraction callback.

How to reproduce

  1. Create awesome app
  2. Use react-navigation for navigation, create NavigationContainer, in my case a Stack Navigator containing a Tab Navigator (Home) and a "Post Details Screen".
  3. Add InteractionManager.runAfterInteractions(() => ...) callbacks in your components (e.g. useEffect() hook)
  4. Callbacks will be called in debug, but never in release

Your Environment

software version
iOS or Android iOS, 13.5.1
@react-navigation/native 5.7.0
react-native 0.63.1
expo /
node v14.4.0
npm or yarn npm, 6.14.6
@mrousavy mrousavy added the bug label Jul 18, 2020
@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • @react-navigation/native

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

@github-actions
Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 5.6.1, latest: 5.7.0)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@mrousavy
Copy link
Sponsor Author

Also, since I'm not entirely sure if this issue is caused by react-navigation, I have opened an issue at react-native as well. facebook/react-native#29421

@mrousavy
Copy link
Sponsor Author

Since I configure each of my animations to not block the InteractionManager (setting isInteraction: false in the config at Animated.timing, .spring, etc), there has to be some reference to the InteractionManager in react-navigation which never gets released... See: facebook/react-native#8624

@github-actions
Copy link

Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible.

The easiest way to provide a repro is on snack.expo.io. If it's not possible to repro it on snack.expo.io, then please provide the repro in a GitHub repository.

@mrousavy
Copy link
Sponsor Author

@satya164 It's difficult providing an example snack since this issue only happens on production/release builds....

@mrousavy
Copy link
Sponsor Author

Closing this since I'm almost certain this is an issue from react-navigation-shared-element.

satya164 added a commit that referenced this issue Feb 8, 2024
Added failed gesture state to clear interaction manager queue 

**Motivation**

My team ran into an issue on IOS where the user taps somewhere on the
left edge of the screen without any swipe, and upon releasing their
finger, the InteractionManager has one outstanding task in the queue.
And this task can block user interactions wrapped into
`InteractionManager.runAfterInteractions`

It could be related with
#8606 but i'm
not sure

**Test plan**

1. Create a stack with two screen with an ability to navigate by swipe
2. Navigate from screen (1) to screen (2)
3. Tap somewhere in the left edge of the screen
4. After that all actions wrapped into
`InteractionManager.runAfterInteractions` will not work

---------

Co-authored-by: viktoriltimirov <viktor.iltimirov@sbermarket.ru>
Co-authored-by: Satyajit Sahoo <satyajit.happy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants