joltup / react-native-threads

Create new JS processes for CPU intensive work
MIT License
756 stars 142 forks source link

Using main bundle instead of thread bundle in iOS release mode (react-native 0.68.1) #139

Open therealgilles opened 2 years ago

therealgilles commented 2 years ago

I believe this change broke using the correct thread bundle in iOS release mode with react-native 0.68.1, and instead using the main bundle:

THREAD NAME App/Workers/my_worker  // <-- correct path
starting Thread: file:///Users/.../Library/Developer/CoreSimulator/Devices/.../my-app.app/main.jsbundle // <-- wrong bundle

Anyone has a suggestion for a fix?

therealgilles commented 2 years ago

Here is a possible fix in ThreadManager.m but probably not the best one:

//NSURL *threadURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:name fallbackResource:name];
  NSURL *threadURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:name fallbackURLProvider:^NSURL * {
          return [[NSBundle mainBundle] URLForResource:name withExtension:@"jsbundle"];
      }];
RustyTheBoyRobot commented 2 years ago

Can confirm this fixes things for RN 68. I had tried another suggestion of simply removing the fallbackResource param, but that used the wrong bundle for the thread.