Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Native bridge uses an api unsupported by older versions of Android WebView #7620

Open
1 of 3 tasks
malo-malo opened this issue Aug 13, 2024 · 4 comments
Open
1 of 3 tasks
Labels
needs reproduction needs reproducible example to illustrate the issue

Comments

@malo-malo
Copy link
Contributor

malo-malo commented Aug 13, 2024

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2

Installed Dependencies:

@capacitor/cli: 6.1.1
@capacitor/core: 6.1.1
@capacitor/android: 6.1.1
@capacitor/ios: 6.1.1

[success] Android looking great! 👌
[error] Xcode is not installed

Other API Details

$ npm --version
10.5.0

$ node --version
v20.12.1

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Sending fetch request with Request object as a parameter does not set data for request on android

This is a duplicate of #7371, I would just like to point out the cause of the issue.
I would have liked to leave a comment on that issue but it has been closed by ionitron-bot

The problem for android is that the native bridge uses const { body } = request;, which is only supported by versions >= 105 of the Android WebView (see MDN docs). Therefore the body is undefined, and missing in the final request.

Expected Behavior

The body should be added to the request

Project Reproduction

https://github.com/malo-malo/capacitor-android-encoding (tag origin android-request-body-issue)

Run the project in web : you can see te body is set when clicking both buttons
Run the android project : the body is set with the first button, not with the second
(Note that I am running this on Android WebView 103 on Android 13)

Additional Information

No response

@jcesarmobile jcesarmobile added the needs reproduction needs reproducible example to illustrate the issue label Aug 14, 2024
Copy link

ionitron-bot bot commented Aug 14, 2024

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.
Please see the Contributing Guide for how to create a Sample App.
Thanks! Ionitron 💙

@ionitron-bot ionitron-bot bot removed the triage label Aug 14, 2024
@Ionitron Ionitron added needs reply needs reply from the user and removed needs reply needs reply from the user labels Aug 14, 2024
@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Aug 14, 2024
@jn42lm1
Copy link

jn42lm1 commented Aug 22, 2024

Might be related to #6174

@Ionitron Ionitron removed the needs reply needs reply from the user label Aug 22, 2024
@malo-malo
Copy link
Contributor Author

@jn42lm1 the issue is not exactly the same
The fix you mention in #6174 has since been implemented (here #6868)

window.fetch = async (resource, options) => {
    const request = new Request(resource, options);
    ...
    const { method } = request;

The problem I mention in this issue is the one you actually noted in your PR #6175

Unfortunately this solution will only work on Chromium 105 browsers and upwards. The reason for this is that the Request object makes the body completely opaque on earlier browser. In 105 and new property was added for Request.body that allows for the body to be read from a ReadableStream. I'll thus close the PR, as it would not be suitable to have a feature in Capacitor that is above the advertised browser support level.

@malo-malo

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction needs reproducible example to illustrate the issue
Projects
None yet
Development

No branches or pull requests

4 participants