Skip to content

Commit c2c9bf0

Browse files
committed
fix: make ios scrollintoview burst-scroll faster
1 parent 05d8291 commit c2c9bf0

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

src/utils/interactors.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,27 +160,34 @@ function iosRunnerOverrides(device: DeviceInfo, ctx: RunnerContext): IoRunnerOve
160160
);
161161
},
162162
scrollIntoView: async (text) => {
163-
const maxAttempts = 8;
164-
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
165-
throwIfCanceled();
166-
const found = (await runIosRunnerCommand(
167-
device,
168-
{ command: 'findText', text, appBundleId: ctx.appBundleId },
169-
runnerOpts,
170-
)) as { found?: boolean };
171-
if (found?.found) return { attempts: attempt + 1 };
172-
// Increase traversal speed on long lists while still checking visibility between chunks.
173-
const swipesPerAttempt = Math.min(4, 1 + Math.floor(attempt / 2));
174-
for (let i = 0; i < swipesPerAttempt; i += 1) {
163+
// Check once, then scroll in bursts to avoid slow find->swipe->find cadence on heavy screens.
164+
const initial = (await runIosRunnerCommand(
165+
device,
166+
{ command: 'findText', text, appBundleId: ctx.appBundleId },
167+
runnerOpts,
168+
)) as { found?: boolean };
169+
if (initial?.found) return { attempts: 1 };
170+
171+
const maxBursts = 12;
172+
const swipesPerBurst = 4;
173+
for (let burst = 0; burst < maxBursts; burst += 1) {
174+
for (let i = 0; i < swipesPerBurst; i += 1) {
175175
throwIfCanceled();
176176
await runIosRunnerCommand(
177177
device,
178178
{ command: 'swipe', direction: 'up', appBundleId: ctx.appBundleId },
179179
runnerOpts,
180180
);
181+
// Small settle keeps gesture chain stable without long visible pauses.
182+
await new Promise((resolve) => setTimeout(resolve, 80));
181183
}
182184
throwIfCanceled();
183-
await new Promise((resolve) => setTimeout(resolve, 300));
185+
const found = (await runIosRunnerCommand(
186+
device,
187+
{ command: 'findText', text, appBundleId: ctx.appBundleId },
188+
runnerOpts,
189+
)) as { found?: boolean };
190+
if (found?.found) return { attempts: burst + 2 };
184191
}
185192
throw new AppError('COMMAND_FAILED', `scrollintoview could not find text: ${text}`);
186193
},

0 commit comments

Comments
 (0)