Comments (2)
I haven't found a solution to the problem online, but I think it may be related to the WebViewAssetLoader class?
You're suspicion is right here.
For context...
The WebViewAssetLoader is part of the android SDK and it effectively intercepts local connections within the webview's network stack going to a specific domain (in this case `https://localhost`). Any connections opened up outside of the webview against `https://localhost` isn't intercepted.Connections opened up in the dev tools is an independent webview that isn't even running on the device itself, it runs in a chrome browser on your local workstation. So the https://localhost
endpoint ends up pointing at our own workstation instead. If you don't have a web server listening on port 443, then your machine will refuse connections, hence the ERR_CONNECTION_REFUSED
error.
Note that even if you were using a filesystem based strategy which doesn't use the WebViewAssetLoader, this issue still manifests in a slightly different way, but if the file://
points to a real path on your local machine then source maps I believe it will work. Issues will probably manifest if you're working with teams and you're using a build bundled by another machine.
The workaround is to inline your source maps. I'm not sure what tools you're using but using inlineSourceMap
may not be enough if you're importing dependencies that also has source maps, and if they distribute via an external sourcemap file (as that's generally recommended for production releases).
Workaround with webpack...
The `source-map-loader` can be used to lift sourcemaps from any imported dependencies to the main application being bundled, which is configured to use `inline-source-map` devtool:{
devtool: 'inline-source-map',
...,
module: {
rules: [
...,
{
test: /\.js$/,
enforce : 'pre',
use: ["source-map-loader"],
include: [
Path.resolve(__dirname, 'src'),
// Include paths to packages that you want source map files to be lifted.
// Including the entire_node_modules may blow up your file size
// But could be a valid strategy for debug builds.
Path.resolve(__dirname, 'node_modules/tp-app-common'),
Path.resolve(__dirname, 'node_modules/tp-mobile-common'),
Path.resolve(__dirname, 'node_modules/@totalpave')
]
}
]
}
}
More details about source-map-loader webpack plugin can be found here
Other bundlers I'm not sure if they are workarounds, you may have to ask for their support if it is possible to lift the source-maps up so that they become a source-map for the bundled application. For webpack, source-map-loader exists because webpack bundles tends to break source maps of imported dependencies to begin with, so source-map-loader addresses that issue, which conveniently also corrects the caveat with source maps on webview mobile applications as well.
I'm closing this issue because there isn't anything that Cordova can do to really address this problem. The main issue is devtool window doesn't route requests through the webview's network stack, and thus it doesn't get intercepted by the app's webview asset loader. That's something only the Chromium team can sort out.
If you're using another build tool then you can try asking in our discussions to see if anybody else have found the workaround using the same build tools.
from cordova-android.
So the
https://localhost
endpoint ends up pointing at our own workstation instead. If you don't have a web server listening on port 443, then your machine will refuse connections, hence theERR_CONNECTION_REFUSED
error.
Not something that I have tried but if you have the technical knowledge to configure webservers.... setting up a local webserver with a self-signed trusted certificate that serves the map files might actually work.
from cordova-android.
Related Issues (20)
- Mixed translations for native date picker on Android HOT 5
- Missing privateHelpers.extractStringFromManifest method. HOT 1
- Android 14 support ? HOT 1
- Incoming Call FullScreen Intent On A Cordova Activity HOT 1
- `ErrorURL` preference is not working HOT 2
- cordova-android build tools not found issue HOT 1
- Will Cordova Android 13 support Kotlin 1.9.x ? HOT 2
- Failed to register a ServiceWorker with Cordova 10 HOT 6
- Target date for support to API34 HOT 2
- cordova-android12.0.1 onRequestPermissionsResult never used HOT 1
- Cordova app on Android crashes after choosing file with native HTML file input, only on Android 13 HOT 3
- Update docs in regards to using adaptive icons with background colors HOT 3
- Splash screen icon not show at first launch HOT 1
- Execution failed for task ':app:mergeReleaseResources'. HOT 2
- Panoramic images HOT 1
- backgroundMode plugin quirks HOT 2
- Cordova undefined when AndroidInsecureFileModeEnabled set to false HOT 2
- Detected 'avdmanager' command but no 'tools\bin' directory found near. HOT 2
- Push Notifications on Android 13 and higher devices HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-android.