Skip to content

Conversation

@kbulgakov-exo
Copy link

Continues #47 and allows consumers to configure the timeout value. Even 500ms sometimes is not enough, the first load for a relatively heavy-component with multiple renders might be up to 800ms in Dev based on my testing

My use-case is a hidden WebView, I'd like to be able to choose an arbitrary huge value because freezing the UI won't be an issue

Testing

Can be tested with this patch:

diff --git a/apple/RNCWebViewManager.m b/apple/RNCWebViewManager.m
index 54e2035..789af70 100644
--- a/apple/RNCWebViewManager.m
+++ b/apple/RNCWebViewManager.m
@@ -254,18 +254,23 @@ shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
   _shouldStartLoadLock = [[NSConditionLock alloc] initWithCondition:arc4random()];
   _shouldStartLoad = YES;
   request[@"lockIdentifier"] = @(_shouldStartLoadLock.condition);
+  NSDate *startTime = [NSDate date];
   callback(request);
 
   NSInteger timeoutMs = webView.shouldStartLoadTimeout;
+  RCTLogWarn(@"shouldStartLoad using timeout: %ldms", (long)timeoutMs);
   NSTimeInterval timeoutSeconds = timeoutMs / 1000.0;
 
   if ([_shouldStartLoadLock lockWhenCondition:0 beforeDate:[NSDate dateWithTimeIntervalSinceNow:timeoutSeconds]]) {
+    NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:startTime] * 1000;
+    RCTLogWarn(@"shouldStartLoad JS response took %.2fms", duration);
     BOOL returnValue = _shouldStartLoad;
     [_shouldStartLoadLock unlock];
     _shouldStartLoadLock = nil;
     return returnValue;
   } else {
-    RCTLogWarn(@"Did not receive response to shouldStartLoad in time, defaulting to NO");
+    NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:startTime] * 1000;
+    RCTLogWarn(@"Did not receive response to shouldStartLoad in time (%.2fms), defaulting to NO", duration);
     return NO;
   }
 }

  • The "using timeout" log should print 500ms when no parameter is passed (the default value)
  • The "using timeout" log should print the number you pass
  • You should see the "Did not receive response to shouldStartLoad in time" log when the parameter is too low

@kbulgakov-exo kbulgakov-exo requested review from a team and ChALkeR January 13, 2026 22:05
@kbulgakov-exo kbulgakov-exo self-assigned this Jan 13, 2026
Copy link
Author

@kbulgakov-exo kbulgakov-exo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

  • The "using timeout" log should print 500ms when no parameter is passed (the default value)
  • The "using timeout" log should print the number you pass
  • You should see the "Did not receive response to shouldStartLoad in time" log when the parameter is too low

Copy link

@guten-exodus guten-exodus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

The use case is for wallet connect? Didn't you already solve it by using the html source?

@kbulgakov-exo
Copy link
Author

The use case is for wallet connect?

Yes

Didn't you already solve it by using the html source?

It looks like it was too early to celebrate. This week I've been making the component more useful (bundle injection, handling messages from the WebView etc) and I hit the loading issue again. This time I put some logs, and realized that the webview native code is actually still checking the origin even with HTML as a source.

@guten-exodus guten-exodus requested a review from 633kh4ck January 14, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants