-
Notifications
You must be signed in to change notification settings - Fork 86
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
Android: DemoHybridApp fails to build due to 'networkSecurityConfig' #445
Comments
This is a substitution coming from modules/hybridapp/ANDROID_application_attributes, with the file included being in apps/DemoHybridApp/xml/network_security_config.xml, though my version of the latter is slightly different allowing cleartextTraffic only on localhost (which i added in 2e32b1b)? It was introduced in fc9cfce but I don't know why this file is not getting pulled into your package; the transfer happens in targets/android/build-binary#L245 |
I just checked: the xpm file is copied ~/.lambdanative/tmp_build/res/xml/network_security_config.xml in line 252 and is still there when I stumbled across this, but don't know what to make of it: |
I am building with an |
Update: It seems from #440 (comment) that you are building for an |
You are right. I changed to There remains an issue though: The compiled apk is installable, but when run it complains about "localhost not found". Did something change in android that localhost is not resolved to 127.0.0.1 any more? If yes, then I'd suggest to use 127.0.0.1 in
|
IMO this should break nothing. I tried the android emulator on linux, but it does not work: the amd64 systemimage boots, but cannot run the arm64 programs. The arm64 systemimage does not boot at all. So without a real device debugging is a bit hard :) |
I believe you can make a targets/android/host_linux_x86_64 file with this content (based on macOS - I didn't try this):
|
That's nice, this work on linux, too. I can upload |
That sounds like a permission problem! Unfortunately, I don't know which part you refer to - does the app fail both on a physical device and the simulator? The 'localhost' IP for the desktop behind the simulator maybe 10.0.2.2, not 127.0.0.1 (as the emulator runs behind a virtual router - see https://developer.android.com/studio/run/emulator-networking). I don't have a physical android device to test with but might be able to look more into the simulator over the weekend. |
Yes, both fail (real device and emulator) with the same error message. I tried:
I do not connect to the sim from outside the sim, that would not work without "black magic". But the webview part of the hybrid app all should connect to localhost (sim loopback device) and the lambdanative part should do the same (connect to loopback device inside the sim). I just found that "localhost" is resolved to 127.0.0.1 in the sim (as one would expect) - not 10.0.2.2. That should still be the same on real devices. Leaves a permission problem as the root of all evil. |
Looks like the lambdanative part of hybridapp does not get a listen socket: |
Interesting, I assumed that |
Not much progress, but it seems that on Android the thread made with |
So (thread-start! ...) does not work on android any more?
|
I don't know. I am looking for regressions going back to older versions of LambdaNative and the Android SDK, but I will have time to review this more next week. It could also be a simulator problem, but I don't have recent Android hardware to test with. |
Well, the problem is the same on real hardware - but I don't know enough about android internals to debug that efficiently.
|
Yes, the problem with threads not running on newer Android devices is the same on real hardware, and it seems to be the case regardless of API targets (I tried 24, 26, 31, based on 24) for Gambit 4.9.2. I have yet to identify where this regression happened as previous builds (with custom toolchains, targeting 28 based on 26) work fine. |
This patch gets the web server to connect ... It also seems Android doesn't like nested threads?
|
See if 74f3a10, which implements the comment above, helps; otherwise, please suggest alternatives, but the root cause is threads are not bing activated or are hanging. The issue is limited to Gambit 4.9.2 (libgambit) but it works flawlessly with Gambit 4.7.9 (libgambc) regardless of the patch. |
Well, mixed success with gambit 4.7.9:
- DemoHybridApp compiles and works inside the x86 emulator
- Democube compiles but does not work inside the x86 emulator (black screen)
- My own Demoapplication (that uses some threads) compiles and the WebView connects to the local server, but the screen stays blank/white with header when run inside the x86 emulator --> only one thread is running (the webserver) but it is not fully functional and no other threads are running.
I remember not too long ago I jumped to gambit 4.9.2 due to the old gambit not building on arm64. So IMO gambit 4.7.9 is not really an option if your hardware is not ancient.
…--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
|
This github 2FA is getting on my nerves, I will quit using my account. Is there an other way to send issues and comments?
As for now I 've seen these 2 lines:
+ ;; It is unclear what this does, but it is needed on Gambit 4.9.2 to run on newer Android devices
+ (if app:android? (thread-sleep! 0.01))
Android suspends processes and threads if they don't yield to the OS on regular intervals. IMO this is done in lambdanative with the heartbeat function, but this only works for the thread that calles this function. All other theads will have to do the same call or be suspended. Might be the cause of this problem.
…--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
|
I am sorry to hear about your struggles with Github. Currently there is no alternative to this process here, as the discussion board we had on Linear was merged into Github too, and email doesn't scale well. As for the sleeping piece, it is a hack but happens to work, so until we get better solutions, we have to use trial and error here. I don't use Android a lot so my abilities to troubleshoot and develop on it are limited - sorry. |
Now this is OT, but a forum would most likely be a better way to build community than the github issue tracker. At least it would be searchable in a sane way (that is, if it's not disourse forum).
At the moment I can't get lambdanative working for iOS devices at all (the other issue) or android (hybridapp), which is quite a pitty. The reasion to jump for hybridapp in the first place was that it works around the GUI rendering & layout issues the GL applications suffer - and that the webview offers all the bells and whistles you would have to build glue layers otherwise, i.g. live camera feed.
…--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
|
There is https://github.com/part-cw/lambdanative/discussions. As far as I know hybrid apps work on Android and other than gambit not compiling on an arm mac with the latest macOS I am not aware of other iOS building problems either. |
@ discussion: that still ues guthub 2FA ...
Anyway, I think I have found the problem (gambit 4.9.2 - but should be the same for 4.7.*): "new" android webview does not allow page reloads, neither from javascript nor from <meta ...>. So everything that would like the page (or part of it) be reloaded fails. Usually there would be some debug output, but don't ask me where android sends that.
Looks like this is the solution, but where should thi go?
https://stackoverflow.com/questions/34979010/reloading-a-webview-with-a-javascript-call-from-a-loaded-web-page
…--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
|
Yes, we used to have the separate https://spectrum.chat/lambdanative became Github Discussions in 2018. If there is a different community we should try I am happy to do give it a shot - but I can't dedicate a lot of time building a community elsewhere, sorry. Logfiles on Android appear in the /sdcard/Android/data/[SYS_ORGSLD_REVERSE]/files/log (you might have to create the log folder) as that is the most accessible location on Android devices - see 212ab34. The link you provide is a new feature to reload the entire WebView (and the backend?) not just refresh a page - I think the example in one of your previous issues that had the counter worked though? |
Oh, and there is most likely a second cops buried:
```
$ adb logbridge
[...] cr_AwContentsClient: Denied starting an intent without a user gesture, URI http://127.0.0.1:8080/
```
The proposed solution is here - again, I don't know where to put this:
https://stackoverflow.com/questions/33048945/denied-starting-an-intent-without-a-user-gesture-webview-android
…--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
|
https://github.com/part-cw/lambdanative/blob/master/modules/hybridapp/ANDROID_java_oncreate#L8 or anywhere below could work with something like this (the hybridapp webview has a slightly different name than the example):
Nevermind - this is not a setting, you want to do this dynamically, I believe so we'd have to wrap that into a scheme function? |
I think the example in one of your previous issues that had the counter worked though?
Yes, that's how I found out. I don't know why in DemoHybridApp the call to CGI ```get_async(ajax_cmd, function(data) { ... }``` works. Looks like only a subset of JS functions / meta tags make the HybridApp dysfunctional.
…--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
|
Ok, looks this is a viable workaround. Basicly you must not load anything that has a <html> or <bod<> tag, you must not use reload, you must not tinter with the history ... there might be more hidden gotchas, but for now this is a way how to work around the "features" of webview.
It boils down to:
- load a minimal html page
- make a body or div with and id
- replace the inner html art of said div/html from javascript
- don't ever use anything that reloads the page
I'm not sure if you are allowed to use links or if there are sideeffects, too. Now this is an odd way to create web applications, but I remember there was a problem in older weview applications that caused the addressbar to appear when going to an other page (there was a workaround, too, IMO I posted it ther some years ago).
Please see the attachned code for details.
…--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
|
< sigh > |
I just tried to get DemoHybridApp compiling for android. It fails with this error message:
Any idea what to do about this?
The text was updated successfully, but these errors were encountered: