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

feat: add retry once with reconnection to the remote debugger to reduce no response condtion error #2334

Closed
wants to merge 25 commits into from
Closed
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
05432f9
retry with reconnection
KazuCocoa Feb 27, 2024
398744a
recovery with reconnection
KazuCocoa Feb 28, 2024
26702b8
add webviewAtomWaitTimeout
KazuCocoa Feb 28, 2024
9bac2a5
fix lint
KazuCocoa Feb 28, 2024
77d985e
>0
KazuCocoa Feb 28, 2024
050c5fa
correct docs
KazuCocoa Feb 28, 2024
10723c2
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Feb 28, 2024
48f0d58
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Mar 7, 2024
c64d0bd
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Mar 28, 2024
094a1a4
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Apr 9, 2024
89300ca
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Jun 25, 2024
6e091b8
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Jul 10, 2024
9e300a0
Update web.js
KazuCocoa Jul 11, 2024
9bb2616
add ios 17
KazuCocoa Jul 15, 2024
97858d4
tweak the logic
KazuCocoa Jul 15, 2024
920b28f
add FIXME
KazuCocoa Jul 15, 2024
44ec815
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Jul 15, 2024
04167f1
simplify a bit
KazuCocoa Jul 15, 2024
50cda10
Update web.js
KazuCocoa Jul 15, 2024
6958829
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Jul 21, 2024
e8ba758
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Aug 1, 2024
6c62f08
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Aug 9, 2024
9db7b75
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Aug 22, 2024
87b9284
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Sep 18, 2024
de5173e
Merge branch 'master' into webview-retry-with-reconnect
KazuCocoa Oct 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions lib/commands/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const TAB_BAR_POSITION_TOP = 'top';
const TAB_BAR_POSITION_BOTTOM = 'bottom';
const TAB_BAR_POSSITIONS = [TAB_BAR_POSITION_TOP, TAB_BAR_POSITION_BOTTOM];

const RECONNECT_COUNT_ATOMS_IOS17 = 2;

/**
* @this {XCUITestDriver}
* @param {any} atomsElement
Expand Down Expand Up @@ -350,10 +352,42 @@ const helpers = {
* @this {XCUITestDriver}
*/
async executeAtom(atom, args, alwaysDefaultFrame = false) {
let promise;
let frames = alwaysDefaultFrame === true ? [] : this.curWebFrames;
let promise = (/** @type {RemoteDebugger} */ (this.remote)).executeAtom(atom, args, frames);
return await this.waitForAtom(promise);

if (
util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '<', '17') ||
util.compareVersions(/** @type {string} */ (this.opts.platformVersion), '>', '17')
) {
promise = (/** @type {RemoteDebugger} */ (this.remote)).executeAtom(atom, args, frames);
return await this.waitForAtom(promise);
}

// The web inspector could behave as no response over the timeout, especially with iOS/iPadOS 17 family.
// Then, reconnecting the remote debugger could help to recover the condition.
// FIXME: Remove this reconnect logic after dropping iOS 17.
for (const retryCount of _.range(RECONNECT_COUNT_ATOMS_IOS17)) {
try {
promise = (/** @type {RemoteDebugger} */ (this.remote)).executeAtom(atom, args, frames);
return await this.waitForAtom(promise);
} catch (err) {
if (!(err instanceof errors.TimeoutError)) {
throw err;
}

this.log.warn(`Retrying to send the same request after re-connecting to the Web Inspector. (${retryCount})`);
const currentContext = this.curContext;

await this.stopRemote();
this.remote = null;

await this.connectToRemoteDebugger();
await this.setContext(`WEBVIEW_${currentContext}`);
}
};
},


/**
* @this {XCUITestDriver}
* @param {string} atom
Expand Down
Loading