You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "mzealey (via GitHub)" <gi...@apache.org> on 2024/11/16 10:02:41 UTC

[I] Web Worker breaking change between android 12 and 13 [cordova-android]

mzealey opened a new issue, #1747:
URL: https://github.com/apache/cordova-android/issues/1747

   I'm not sure if this is a bug report or more of a useful note to help others in the future...
   
   I have an app which is using `new Worker('file.worker.js)` to load a webworker from the cordova build. This was working just fine in cordova-android 12, and seems to be working fine on *some* devices with cordova-android 13 (including, frustratingly, SDK 30/34 emulators). However on some end-user devices including my own this resource loading just gets blocked with no explanation. I have `<preference name="AndroidInsecureFileModeEnabled" value="true" />` set etc and historically there have been no problems.
   
   I cannot see any way to get this working still using the default `file:` cordova loading, however in my case the fix seems to be relatively simple - I just had to use the below to move from `file:` uri access to the inbuilt webserver:
   
   ```
         <content src="https://localhost/index.html" />
   ```
   
   This obviously messes with `localStorage` etc settings that users already did, which is somewhat frustrating, but at least the user interface now works correctly.
   
   I cannot see this documented anywhere; it may well be due to the `targetSdk` upgrade but it feels to me like a breaking change (as per above, only on some devices), which should be added to the release notes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [I] Web Worker breaking change between cordova-android 12 and 13 [cordova-android]

Posted by "mzealey (via GitHub)" <gi...@apache.org>.
mzealey commented on issue #1747:
URL: https://github.com/apache/cordova-android/issues/1747#issuecomment-2480505878

   Actually I'm a little unsure if it's between 12-13 or from an earlier version - based on user reports and rollout %ages it may have been broken earlier than this on some devices.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [I] Web Worker breaking change between cordova-android 12 and 13 [cordova-android]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #1747:
URL: https://github.com/apache/cordova-android/issues/1747#issuecomment-2487323346

   web workers are subjected to the same-origin policy. That is a document that loads a web worker must do so from within the same origin. Features that require same-origin isn't support to work properly on `file://` because `file://` is considered an opaque origin. The browser is suppose to assume that two resources from opaque origins to be not from the same origin. This means a document loaded over `file://` that wants to load a web worker will not be able to because that web worker script is automatically considered to be cross-origin.
   
   If it worked before, then it was likely a bug inside the chromium webview that has been since corrected.
   
   Not using `AndroidInsecureFileModeEnabled` (or setting it to false, which is the default value) makes cordova uses something called the `WebViewAssetLoader` which allows the webview content to be served through `https://localhost` (or another hostname of your choice), which gives the document an origin, for the purposes of features requiring same-origin. It also gives your webview a secure context flag if `https` protocol is used for features requiring a secure context. So it's definitely recommended to keep `AndroidInsecureFileModeEnabled` turned off.
   
   > Actually I'm a little unsure if it's between 12-13 or from an earlier version - based on user reports and rollout %ages it may have been broken earlier than this on some devices.
   
   I'm assuming this was a bug inside the chromium webview. The bug might be breaking but the behaviour of web workers being loaded over `file://` isn't suppose to happen to begin with. If that's the case, then it's not a matter of cordova-android version. It will depend on what webview version is installed on the user's device. I'm guessing the change was introduced in ~ v130 based on https://issues.chromium.org/issues/377230203
   
   I don't think there is anything actionable here by Apache Cordova. The solution is to remove `AndroidInsecureFileModeEnabled` or work towards a migration plan to stop using the `file://` hosted apps, so I'll be closing this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [I] Web Worker breaking change between cordova-android 12 and 13 [cordova-android]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek closed issue #1747: Web Worker breaking change between cordova-android 12 and 13
URL: https://github.com/apache/cordova-android/issues/1747


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org