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

In development, WPiOS freezes for up to one minute when trying to open the block editor #2944

Closed
guarani opened this issue Dec 29, 2020 · 2 comments · Fixed by #3258
Closed
Assignees
Labels

Comments

@guarani
Copy link
Contributor

guarani commented Dec 29, 2020

Describe the bug

This is a non-user facing bug that only affects the developer workflow on physical devices.

When opening the block editor from within WPiOS, it often happens that the editor freezes for one minute before loading. I think this issue has been around for over a year and has something to do with React Native waiting to find a running packager. In this scenario, there is no running packager so the app should load the pre-loaded bundle immediately.

To Reproduce

  1. Compile and run WPiOS develop branch (which uses the default Debug build config) on a physical device
  2. Ensure the device's WiFi connection is Off
  3. Open the block editor
  4. Notice that the entire app freezes for about 1 minute before the editor loads

Expected behavior
The editor should load normally in a couple of seconds.

Smartphone (please complete the following information):

  • Device: iPhone 11
  • OS: 14.2
  • Version WPiOS develop

Additional info
Turning on Airplane mode sometimes "fixes" this.

@hypest
Copy link
Contributor

hypest commented Jan 4, 2021

Compile and run WPiOS develop branch

👋 Paul, not sure, which build would that be though? I understand is off the develop branch but it's not clear if that's a release build or a debug build.

Debug builds should prioritize using the packager since that's the expected developer flow. Perhaps what we can explore is to reduce the timeout so the app looks for the embedded bundle sooner?

@guarani
Copy link
Contributor Author

guarani commented Jan 4, 2021

which build would that be though?

It's on the Debug build (I edited the issue above to specify this now).

Debug builds should prioritize using the packager since that's the expected developer flow. Perhaps what we can explore is to reduce the timeout so the app looks for the embedded bundle sooner?

Yeah, I think so too. There's some suggestion of just using a release build, but I don't think that's the solution.

IIRC, the app hangs until this network request that checks for a running packager times out (taken from Pods/React-Core/Default/RCTBundleURLProvider.m:

- (BOOL)isPackagerRunning:(NSString *)host
{
  NSURL *url = [serverRootWithHostPort(host) URLByAppendingPathComponent:@"status"];

  NSURLSession *session = [NSURLSession sharedSession];
  NSURLRequest *request = [NSURLRequest requestWithURL:url];
  __block NSURLResponse *response;
  __block NSData *data;

  dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  [[session dataTaskWithRequest:request
            completionHandler:^(NSData *d,
                                NSURLResponse *res,
                                __unused NSError *err) {
              data = d;
              response = res;
              dispatch_semaphore_signal(semaphore);
            }] resume];
  dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

  NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  return [status isEqualToString:@"packager-status:running"];
}

I haven't looked into this deeply, and I wonder if this timeout is user-configurable in React Native.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants