Setting a timer for a long period of time, i.e. multiple minutes
I want to use firebase auth with react native for Login and Signup but I got a yellow error: 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. (Saw setTimeout with duration 111862ms)
How Can I Fix That? I don't want to ignore that, I want to understand this error and solve that with the best and Standard way. And This is my Code:
export default class Login extends Component {
constructor(props) {
super(props)
this.state = {
email: '',
password: '',
response: ''
}
this.signUp = this.signUp.bind(this)
this.login = this.login.bind(this)
}
async signUp() {
try {
await firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
this.setState({
response: 'Account Created!'
})
setTimeout(() => {
this.props.navigator.push({
id: 'App'
})
}, 1500)
} catch (error) {
this.setState({
response: error.toString()
})
}
}
async login() {
try {
await firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
this.setState({
response: 'user login in'
})
setTimeout(() => {
this.props.navigator.push({
id: 'App'
})
})
} catch (error) {
this.setState({
response: error.toString()
})
}
}
render() {
return (
<View style={styles.container}>
<View style={styles.containerInputes}>
<TextInput
placeholderTextColor="gray"
placeholder="Email"
style={styles.inputText}
// onChangeText={(email) => this.setState({ email })}
onChangeText={(email) => {console.log(email);}}
/>
<TextInput
placeholderTextColor="gray"
placeholder="Password"
style={styles.inputText}
password={true}
onChangeText={(password) => this.setState({ password })}
/>
</View>
<TouchableHighlight
onPress={this.login}
style={[styles.loginButton, styles.button]}
>
<Text
style={styles.textButton}
>Login</Text>
</TouchableHighlight>
<TouchableHighlight
onPress={this.signUp}
style={[styles.loginButton, styles.button]}
>
<Text
style={styles.textButton}
>Signup</Text>
</TouchableHighlight>
</View>
)
}
}
I Asked From Stackoverflow too, Link
Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.
Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.
I assume you are including real-time database in your code? We pro-actively refresh the token when database or other Firebase services are included. The token typically has a lifetime of one hour. We would need to use some other native utility or external dependency to replace the underlying setTimeout usage for this. This will take some time to implement. It seems benign for now so I see this as a low priority.
Yeah I'm using real-time database and when I added firebase to my project, I got This
Thank you @bojeil-google
@bojeil-google Could you please update here when this has been resolved? Thank you!
constructor() {
super();
console.ignoredYellowBox = [
'Setting a timer'
];
}
I wonder, this issue show up only in Android, and maybe it's caused by using react-navigator, I say this, because once I all repeat from tutorial and tutor doesn't get this error and only difference between our works it's I use react-navigator instead react-native-router-flux and I work with Android instead IOS
Maybe, we could throw this code below in to the project, and reset all setTimeout ?
const highestTimeoutId = setTimeout(() => ';');
for (let i = 0; i < highestTimeoutId; i++) {
clearTimeout(i);
}
// source: https://stackoverflow.com/questions/3847121/how-can-i-disable-all-settimeout-events
When will This issue be resolved?
There are bunch of high priority features and bug fixes in the pipeline. We'll switch to this issue immediately after. It's been labeled as a P3 issue which is appropriate for its severity.
Hello guys, any update on this issue please? I have not been able to use Firebase on Android because of it.
Using the native sdk instead of the js/web sdk fixes the problem.
https://github.com/invertase/react-native-firebase
It involves a lot more configuration and it won’t work with Expo tho.
My understanding is that this is not a blocking issue and can be suppressed. I will try to experiment with a quick solution using react-native-background-timer and report back.
Ok, I tried testing this issue with react native 0.48.4 and firebase 4.6.2 using an Android emulator (API 25) and I was not able to replicate this. I am not getting the warning at all.
I am still getting this warning
Can you provide more detailed information about your environment to facilitate replication?
I use Expo and get this error. Perhaps it is specific to Expo, which may be why you did not get an error on your emulator.
On Tue, Nov 28, 2017 at 2:38 AM, bojeil-google [email protected] wrote:
Can you provide more detailed information about your environment to facilitate replication?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-js-sdk/issues/97#issuecomment-347438764, or mute the thread https://github.com/notifications/unsubscribe-auth/AdTknxE4yq8eD5wXOenm_14wg7o8KCJ1ks5s67h7gaJpZM4OYphr .
I also used expo version ^21.0.0.
Getting the same warning here (not using Expo)
expo ^23.0.0 and getting this error on emulator and android device