Skip to content

requestIdleCallback may never fire again after app is backgrounded #17645

Description

@berickson1

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Latest Expo App: SDK 24
Target Platform: Android 7.0

Steps to Reproduce

  1. Run Expo Sample https://snack.expo.io/r1HW4J0EG
  2. Background Expo Sample
  3. Foreground Expo Sample

This occurs if I always maintain at least one setIdleCallback queued at the time the app is backgrounded.

Expected Behavior

Counter continues to increment

Actual Behavior

Counter stops running

Reproducible Demo

https://snack.expo.io/r1HW4J0EG

export default class App extends Component {
  doIdleWork() {
    requestIdleCallback(() => {
      this.setState({number: this.state ? this.state.number +1 : 0 });
      // setup another requestIdleCallback before we're done
      this.doIdleWork();
    });
  }
  componentDidMount() {
    this.state = { number:1 };
    this.doIdleWork();
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.paragraph}>
         {this.state ? this.state.number : 0 }
        </Text>
        <Card title="Local Modules">
          <AssetExample />
        </Card>
      </View>
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions