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

Android timers (setTimoout and animation delay) are missbehaving ! #14639

Closed
fabien-h opened this issue Jun 20, 2017 · 6 comments
Closed

Android timers (setTimoout and animation delay) are missbehaving ! #14639

fabien-h opened this issue Jun 20, 2017 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@fabien-h
Copy link

Description

When I :

setTimeout(
	e => this.props.selfClose(),
	5000
);

It happens with immediately. Same with :

Animated.timing(
	this.state.opacity, {
		toValue: 1,
		duration: 250,
		easing: Easing.out( Easing.back( 2 ) ),
		useNativeDriver: true,
		delay: 5000,
	}
).start();

There is an almost zero delay before the animation is played.

iOs works fine.

Reproduction Steps & Sample Code

Steps :

  • react-native init testreactnative
  • plug android device
  • add code in /index.android.js
  • run in device with the react native debugger
  • see the log

Code to add :

componentDidMount() {
	let initTime = new Date().getTime();
	console.log( new Date().getTime() - initTime, 'foo' );
	setTimeout(
		e => {
			console.log( new Date().getTime() - initTime, 'bar' );
		},
		5000
	);
	console.log( new Date().getTime() - initTime, 'baz' );
};

Logs :

0 "foo"
0 "baz"
64 "bar"

So technically, there is a delay. But 64ms is not what I asked.

Now the weird part. If I set the delay to 10.000 instead of 5.000, it logs 4672 "bar". Not even linear. And if I go up to 100.000, I get this warning :

YellowBox.js:76 Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.

Additional Information

  • React Native version: 0.45.1
  • Platform: Android ; I run on device (shitty tablet)
  • Development Operating System: macOS
  • Build tools: [FILL THIS OUT: Xcode or Android Studio version, iOS or Android SDK version, if applicable]
@orenklein
Copy link

+1

@githubdoramon
Copy link

+1

@githubdoramon
Copy link

It seems that the bug only happens whit JS debug on

@fabien-h
Copy link
Author

Yes, as described ; debug mode with a debugger opened. So not blocking ; just annoying when building the app.

@hramos
Copy link
Contributor

hramos commented Sep 21, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Sep 21, 2017
@hramos hramos closed this as completed Sep 21, 2017
@nikhiysham
Copy link

nikhiysham commented Sep 26, 2017

I also facing this issue. Is this gonna effect Android performance since the initial load is slowly compare to ios.

@facebook facebook locked as resolved and limited conversation to collaborators Sep 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants