Reputation: 1
I'm encountering an issue where polling in a WebView stops working on Android 15 after opening Chrome Custom Tabs. The polling works perfectly fine on Android 14 and below, but once I open Chrome Custom Tabs, the XMLHttpRequest goes into a pending state and no API response is received.
I have a simple HTML page (pollingtest.html
) with a JavaScript polling mechanism that makes an API call every second to fetch data.
pollingtest.html
<!DOCTYPE html>
<html>
<body>
<div id="demo">
<h1>The Polling Test Android</h1>
</div>
<script>
// Function to make the API call and update content
function getValue() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
console.log("API Response:", this.responseText);
}
};
// Fetch the data every 1 second
xhttp.open("GET", "https://api.coindesk.com/v1/bpi/currentprice.json", true);
xhttp.send();
}
// Start calling the API every 1 second as soon as the page loads
window.onload = function() {
setInterval(getValue, 1000); // Call getValue every 1000ms (1 second)
};
</script>
</body>
</html>
The HTML file is loaded into a WebView using the following code:
webview.loadUrl("file:///android_asset/pollingtest.html");
After 5 seconds, Chrome Custom Tabs is opened using the following code:
new Handler(Looper.getMainLooper()).postDelayed(() -> {
startChromeCustomTabs(); // starts chrome custom tabs after 5 seconds
}, 5000);
After opening Chrome Custom Tabs on Android 15, the XMLHttpRequest in the WebView stops, and the network request enters a "pending" state, as seen in the Chrome network inspector.
The issue only occurs on Android 15; on Android 14 and below, everything works as expected.
Is there a known issue with WebView polling in Android 15 that causes network requests to hang when Chrome Custom Tabs is opened? Is there a workaround or solution to ensure the polling continues to function correctly after launching Chrome Custom Tabs?
Any help or guidance would be greatly appreciated!
Upvotes: 0
Views: 59