Compare commits

...

1 Commits

Author SHA1 Message Date
Manuel Beck
0bbe43b5be fix: log missing optional assets not as exception
- When no plugins are added, `cordova_plugins.js` is not present and will give an error in console: `java.io.FileNotFoundException: www/cordova_plugins.js``
- Chromium tries to load `favicon.ico` which is not present: `java.io.FileNotFoundException: www/favicon.ico`
- Generated-By: GPT-5.3-Codex, GitHub Copilot Chat
2026-03-13 17:24:25 +01:00

View File

@@ -111,6 +111,13 @@ public class SystemWebViewClient extends WebViewClient {
return new WebResourceResponse(mimeType, null, is);
} catch (Exception e) {
// Some files are requested by default but might not exist in a valid project setup.
// When these files are missing, the request should quietly fall through instead of
// being logged as an application error.
if (isOptionalMissingAsset(path, e)) {
LOG.d(TAG, "Optional Web resource not found at \"" + path + "\"");
return null;
}
e.printStackTrace();
LOG.e(TAG, "Exception handling Web resource at \"" + path + "\"", e);
}
@@ -132,6 +139,24 @@ public class SystemWebViewClient extends WebViewClient {
}
}
/**
* Returns `true` when the request failure is expected and non-fatal.
*
* Some web resources are requested by default but might not exist in a valid project setup:
* - {@code cordova_plugins.js} can be absent when no plugins are installed.
* - {@code favicon.ico} is often requested by the WebView/Chromium engine automatically.
*
* When these files are missing, the request should quietly fall through instead of being logged
* as an application error.
*/
private static boolean isOptionalMissingAsset(String path, Exception exception) {
if (!(exception instanceof FileNotFoundException)) {
return false;
}
return "cordova_plugins.js".equals(path) || "favicon.ico".equals(path);
}
/**
* Give the host application a chance to take over the control when a new url
* is about to be loaded in the current WebView.