Don’t trust the WebView: blank screens, bank handoffs, and false returns
Two Android payment bugs looked harmless: a white WebView and a foreground return. Neither meant what it seemed to mean. A QA report said the payment page was "still loading". It was not. The bank page had already tried to leave through bankapp://... , startActivity had failed, and the WebView was stuck on a blank document. The second bug was worse: the customer came back to our activity and we…
Two Android payment bugs, neither initially alarming, proved more serious upon closer inspection. In the first, a blank WebView persisted even after the payment page supposedly loaded. Meanwhile, the second bug caused the customer to be returned to the app prematurely, treated as a successful payment even though the bank page had already attempted to leave.
The customer selects a bank, and if the app is absent, the web client stays within the app, with only the known bank deeplink being provided for handing over the process. The report highlights the challenge of differentiating a dead document from a spinner, and why onResume after the handoff is not a reliable signal. The flow of events includes a blank page after a failed bank intent that returns false, indicating the payment is still pending.
The bank page often redirects back to its own scheme, leaving a blank document behind when the WebView is slow to load. To determine if a page is alive, monitor the readyState, count of element children on the body, and the length of innerText. If any of these indicate a non-empty document, the page is considered alive. If none are present, and the readyState is no longer loading, the document is empty.
In parallel, a hard timeout of 5.5 seconds is set, with a probe running every 150 milliseconds for a maximum of 2.5 seconds. If no usable snapshot arrives within this timeframe, the screen is closed, and the customer is advised to install the app.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to