title: How to implement code with long execution time in React Native?
body: <p>I'm building a new app with React Native and Expo.
  The main function of this app is to generate plans for user.
  The generating algorithm will take estimated around 300-500 seconds to execute. (It contains maximum 2,100,000 times of random generating.)</p>
  
  <p><strong>Currently I am facing two problems:</strong></p>
  
  <p><strong>Q1.</strong> during testing, this piece of code is put in the App.js - App class - render function directly. however, it seems that if the execution time exceeds 32 seconds the app will just fail to render and stay no response forever.</p>
  
  <p>So the question is: </p>
  
  <p><strong>1.1</strong> what's the reason of the maximum 32 seconds otherwise no response?</p>
  
  <p><strong>1.2</strong> are there better ways to do testing?</p>
  
  <p>Current testing method:</p>
  
  <pre><code>export default class App extends React.Component {
    componentDidMount() {
      if (__DEV__) {
        Reactotron.connect();
        Reactotron.log('hello rendering world');
      }
    }
  
    render() {
      //test
      generatePlan(store.getState(), 0);
  
      return (
        &lt;Provider store={store}&gt;
          &lt;AppContainer /&gt;
        &lt;/Provider&gt;
      );
    }
  }
  </code></pre>
  
  <p><strong>Q2.</strong> at the end, it's not possible to let user keep dazing such a long time after click an "generating" button. So ideally, this long executing task should be running in the background with limited resource (both memory and calculating), so that the user can do other things during waiting without too much being influenced(like a virus scanning task, once it finishes, pops up a message, etc.)</p>
  
  <p>So the question here is: </p>
  
  <p>how to implement this?</p>
  
  <p><strong>What I have tried:</strong></p>
  
  <p><strong>For Q1:</strong> 
  currently I have no idea about the reason and even can't figure out the accurate key words to search. 
  (I tried search "react native long execution time", "no response", etc in google, react native github issue, Expo forum, but no luck.)</p>
  
  <p>currently my idea to do testing is to execute each part separately and manually store the result of each part. Then do the final part with the stored result of each part.</p>
  
  <p><strong>For Q2:</strong> 
  There is a library "react-native-background-task": </p>
  
  <p>"This library allows the scheduling of a single periodic task, which executes when the app is in the background or closed, no more frequently than every 15 minutes. Network, AsyncStorage etc can be used (anything except UI), so perfect for things like a background data sync for offline support."</p>
  
  <p>But there are two questions about this potential solution:</p>
  
  <p><strong>a.</strong> how to run task in the background when the app is open?</p>
  
  <p><strong>b.</strong> how to limit the calculating resource used by this task?
  (as the task can be executed slowly, but it shouldn't occupy too much calculating resource if the user is still using the mobile phone.)</p>