Skip to content

PIR: Fix shared webview being destroyed in PIR debug runs#7755

Merged
landomen merged 1 commit intodevelopfrom
fix/domen/pir-debug
Feb 18, 2026
Merged

PIR: Fix shared webview being destroyed in PIR debug runs#7755
landomen merged 1 commit intodevelopfrom
fix/domen/pir-debug

Conversation

@landomen
Copy link
Contributor

@landomen landomen commented Feb 17, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/task/1212923242657599

Description

Shared WebView that is passed to a PIR runner was destroyed between jobs. This delegates the cleanup to the owner of the WebView (activity) instead of to the runner.

Steps to test this PR

QA optional - can run debug scans or opt-outs

UI changes

No UI changes


Note

Low Risk
Small, debug-only control-flow change that avoids calling runner cleanup which destroys the shared WebView; low blast radius outside debug runs.

Overview
Prevents PIR debug scan/opt-out flows from destroying the caller-provided (shared) WebView between sequential steps.

In RealPirScan.debugExecute and RealPirOptOut.debugExecute, removes the per-step runners[0].stop() call (with an explanatory comment), leaving WebView lifecycle/cleanup to the debug WebView owner while still cleaning WebView data at the end of the run.

Written by Cursor Bugbot for commit a3343a9. This will update automatically on new commits. Configure here.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

logcat { "PIR-SCAN: Start thread=${Thread.currentThread().name}, profile=$profileQuery and step=$step" }
runners[0].startOn(webView, profileQuery, listOf(step))
runners[0].stop()
// don't call stop() here to avoid destroying the WebView as it's reused for all steps
Copy link
Contributor

Choose a reason for hiding this comment

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

Shared webview still destroyed on next run

Medium Severity

Removing per-step stop() leaves the debug PirActionsRunner alive in runners, so later cleanup (cleanPreviousRun/cleanRunners) still calls stop() and destroy() on the externally owned webView. This shifts destruction to the next job instead of delegating lifecycle ownership to the activity.

Additional Locations (1)

Fix in Cursor Fix in Web

logcat { "PIR-SCAN: Start thread=${Thread.currentThread().name}, profile=$profileQuery and step=$step" }
runners[0].startOn(webView, profileQuery, listOf(step))
runners[0].stop()
// don't call stop() here to avoid destroying the WebView as it's reused for all steps
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug runner retains shared WebView reference

Medium Severity

With stop() removed, the debug PirActionsRunner keeps detachedWebView pointing to the activity-owned webView after completion, and the runner stays in runners. This can retain the activity Context and WebView resources past the debug session, creating a long-lived memory/resource leak until another cleanup path runs.

Additional Locations (1)

Fix in Cursor Fix in Web

logcat { "PIR-SCAN: Start thread=${Thread.currentThread().name}, profile=$profileQuery and step=$step" }
runners[0].startOn(webView, profileQuery, listOf(step))
runners[0].stop()
// don't call stop() here to avoid destroying the WebView as it's reused for all steps
Copy link
Contributor

Choose a reason for hiding this comment

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

Runner coroutine not canceled after debug completion

Medium Severity

Skipping runners[0].stop() leaves the final engineJob from startOn active after debug runs. awaitResult() keeps collecting sideEffect until stop() cancels it, so the runner keeps a live coroutine in app scope after completion, which can leak work and keep stale runner state alive.

Additional Locations (1)

Fix in Cursor Fix in Web

@landomen landomen merged commit 4d3bb2e into develop Feb 18, 2026
16 checks passed
@landomen landomen deleted the fix/domen/pir-debug branch February 18, 2026 12:44
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.

2 participants