Closed EddyVerbruggen closed 4 years ago
@EddyVerbruggen The only crashes I've ever come across was related to the thread scheduler.
Adding this code:
if (ENV != 'PRODUCTION') {
// for okhttp
let policy = new android.os.StrictMode.ThreadPolicy.Builder().permitAll().build()
android.os.StrictMode.setThreadPolicy(policy)
}
resolved it for me.
In regards to large responses
, my app GoJobYourself scrapes entire web pages using this plugin and I've never had a problem with it on android or ios.
@roblav96 That bit of code is exactly what I had to add to make it work on Android with a simple GET of https://httpbin.org/
.
Why do you only need that when ENV != 'PRODUCTION'
? Does Android not throw those errors for release builds perhaps?
@EddyVerbruggen I have no idea. lol In my past experiences while testing release builds this was never an issue.
@EddyVerbruggen How did you solve this problem?
Like I mentioned in this comment: https://github.com/gethuman/nativescript-https/issues/7#issuecomment-289222847
I have same problem. Sometimes i have android.os.NetworkOnMainThreadException, when i use post request.
@san3k1990 Did you try this suggestion? https://github.com/EddyVerbruggen/nativescript-https/tree/99faa4fc5ae2a6363d8ebb4a09dfa945bc0700a0#android-troubleshooting
@EddyVerbruggen Yes, with allowLargeResponse: true
the problem is gone. Thanks.
Has anybody seen a crash on Android with (slightly) larger responses?
Even a call to https://httpbin.org will crash the app, but the smaller https://httpbin.org/get won't.
It's because of the line
response.body().string()
which runs the main thread and Android detects that as something that can degrade app responsiveness.I have a fix for this in my fork but won't submit a PR until someone else can confirm it's a real issue instead of the way I use it.