-
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
New module lnjscheme #387
base: master
Are you sure you want to change the base?
New module lnjscheme #387
Conversation
1.) Android 9/10 restricts access to JNI and Jave reflection API's. This adds additional checks. Commented out an possible optimization, which could be assumed to works, but does not for me so far. Please leave this comment in, so we recall before we wonder why and try over and over again. Once in a while we should ponder if it still does not work or why. 2.) Clear Java exceptions. This enables to continue to run when an exception occured during a JNI call. (Future versions shall forward this as an exception in Gambit.) 3.) Avoid some JNI calls and provide more information about the Java/Android environment to Scheme. This is required for (upcoming) tricks to still call embedded dynamic libraries as subprocesses. It also enables to figure out a sane path to store app-private data instead of the deprecated hard coding of the publicly accessible path `/sdcard`. 4.) Add support to switch the apps content view to Java and back. An upcoming module `webview` will need this.
Any not-so-time-critical Android API/Java Method - except those restricted Android itself may be called without adding JNI code.
HOLD ON I found a dependency issue in this PR, which leads to an idea of generalization. Stay tuned for updates. |
Co-authored-by: Matthias Görges <[email protected]>
Remove use of length, repeated list traversals and combinations of apply+append.
Apps that use FileProvider to pass URIs to activities must include ANDROID_xml_services and xml/file_paths.xml. Also fixes build-binary to locate the support.v4 library needed for FileProvider. Finally, use onRequestPermissionsResult to bootstrap.java.in to fix permission requests hanging.
Avoid some JNI calls and provide more information about the Java/Android environment to Scheme. Co-authored-by: Matthias Görges <[email protected]>
1) Android 9/10 restricts access to JNI and Jave reflection API's. This adds additional checks. Commented out an possible optimization, which could be assumed to works, but does not for me so far. Please leave this comment in, so we recall before we wonder why and try over and over again. Once in a while we should ponder if it still does not work or why. 2) Clear Java exceptions. This enables to continue to run when an exception occured during a JNI call. (Future versions shall forward this as an exception in Gambit.)
Problem stems from conversion of apply to case-based approach which didn't consider that colors in glCore:TextureDrawUnClipped is now a list of lists. Also patched glCore:TextureDrawClipped
1.) Android 9/10 restricts access to JNI and Jave reflection API's. This adds additional checks. Commented out an possible optimization, which could be assumed to works, but does not for me so far. Please leave this comment in, so we recall before we wonder why and try over and over again. Once in a while we should ponder if it still does not work or why. 2.) Clear Java exceptions. This enables to continue to run when an exception occured during a JNI call. (Future versions shall forward this as an exception in Gambit.) 3.) Avoid some JNI calls and provide more information about the Java/Android environment to Scheme. This is required for (upcoming) tricks to still call embedded dynamic libraries as subprocesses. It also enables to figure out a sane path to store app-private data instead of the deprecated hard coding of the publicly accessible path `/sdcard`. 4.) Add support to switch the apps content view to Java and back. An upcoming module `webview` will need this.
Any not-so-time-critical Android API/Java Method - except those restricted Android itself may be called without adding JNI code.
…into pr-module-lnjscheme
Calling setContentView between permission requests would cause some apps to hang. This problem was previously addressed by adding a shell override function for onRequestPermissionResult, which is no longer needed and is removed in this commit
I am a bit concerned about my ability (or lack thereof) to review this as it makes changes to 52 files (1400 lines of code), most of which have nothing to do with the lnJScheme module and its ties into the event system. There are things that now go merged slightly differently, moving code around, line end changes etc - this is in part the fault of how Github presents it as both this branch and the master have moved forward in different aspects. |
If I'm not mistaken all too much, than these many changes are simply a consequence of the
Yes it does. That allocates a single event number (126) and dispatches to a possibly registered receiver - or is ignored as before.
Sorry for whitespace. I'm slightly visually impaired (a cataract surgery which did not take the 99% turn). I can't see these things.
Yes. Though I can't follow your implications. Personally I'm using this module now for a 14 month, according to git. In principle I feel that this module has the capacity to put an end to (almost) all the endless That's the main idea of the whole thing. Time critical things might still need to have their own JNI. But more or less "simple" calls to Android would be trivial up to the point that one could ship a script file for an alternative to the webview module. b) a webview module that's part of part II: the demo case. (Originally those where two separate branches, but after c) new jScheme related events Belongs to part I: a very simple Scheme interpreter (~32Kb) running on the Java side, possibly within the GUI thread. There is one event number allocated. The implementation is supposed to not fail. d) a demo app for this module? For both the modules. The demo has two buttons:
(((This will hopefully inspire ideas how t get over the need of the extra handling of This webview module is essentially a (stub) application of the lnjscheme module. The idea is to evolve this in to a more capable browser. Right now it's still easier/faster to load than going through the consequences of |
GO AHEAD -- just managed to compile upstream and found it working. Notes on the actual changes:
|
According to my new gained understanding we better free JNI references. See: Note that this MAY have more consequences elsewhere (if true) and MAY explain why Apps don't resume or die after a while. |
- #defines LAMBDANATIVE_JNI_VERSION to JNI_VERSION_1_4 - uses `jint` as if it was an opaque type - checks via GetEnv before attaching a thread (there are claims on the Internet that this may save some overhead) - use AttachCurrentThreadAsDaemon instead of AttachCurrentThread for gut feeling
This appears to be the correct way and seems to actually solve the issue observed and not fixed by da86a5160 ff.
Calling setContentView between permission requests would cause some apps to hang. This problem was previously addressed by adding a shell override function for onRequestPermissionResult, which is no longer needed and is removed in this commit
Allocates a single event number (126) and dispatches it to a possibly registered receiver - or is ignored as before.
Moves LNjScheme from DemoAndroidLNjScheme to its own module. Also updates DemoAndroidLNjScheme to use of ln_jscheme and webview
Moved the 'webview' script from DemoAndroidLNjScheme into a module of its own; this module is a bit of a stub. Might receive updates to become a nicer looking browser. Meanwhile still intended to showcase how to call Java via jScheme
I have tried to merge this in three commits - I can't really test it but it shouldn't have broken existing things in the base LambdaNative implementation. A few todo items, please:
|
Actually also |
Yeah, that's a horrible thing to have, which just happens to work. However the Androidoverlords are likely unhappy no matter what we do. At one of my phones it does NOT work at all. That's bad, but what can we do? Fix Android to enable sane use? Hardly we can.
Maybe it should. At least for documentation how to build the |
TBD
While I can't really follow the motivation behind the rename, I'm not held back with the consequences. As you changed a lot of whitespace in between (which, for visually impaired persons like me, is a really annoying thing to follow as I can not see it) , removed the language and comments controlling syntax highlighting and whitespace policy (similarly) and did this rename all in one change I ran into a huge conflict battle. (If you only had this done step-by-step!!) Now I managed to resolve those conflicts. Code wise that is. The result in practice: none of my apps are really working anymore after It will take time to get a working environment back. |
In principle I don't see why this module should - eventually - be Android specific. Right now it is. But it should be "just a matter of work to be done" to make webkit render on openGL . |
maybe it had been a good idea to include the :-( Edited: or at least the |
It was internally consistent to name it as all ln-functions were of the ln_xxx way.
This was already a ton of work and you also didn't break them into single commit. As we discussed there was no way to merge 27 commits which touched a bunch of unrelated files due to the strange rebase.
Polluting every file with this Emacs thing (at inconsistent places) is super annoying; either find a global setting or some other way to do this. We use Eclipse or vim. I am also worried that this will break things in the Android substitution.
This is surprising as I merged all the files you changed. So not sure why it is now broken on your side? |
I only see a deleted file with this name in the pull request? |
Don't we already have a webview that works for iOS? |
Sorry, what I am pointing out is that we don't have the substitution for it in our build system so this does nothing. |
I believe this is as the .gitignore you merged includes *.jar, which is why it was not in there - am I moving the one from the previous app? |
Am Sun, 29 Nov 2020 11:05:53 -0800
schrieb Matthias Görges <[email protected]>:
>> maybe it had been a good idea to include the `android_jars`
>> subdirectory from the proposed patch into `master`.
> I only see a deleted file in the pull request?
I believe this is as the .gitignore includes *.jar, which is why it
was not in there - am I moving the one from the previous app?
Yes. It's unchanged.
|
Am Sun, 29 Nov 2020 10:58:20 -0800
schrieb Matthias Görges <[email protected]>:
> Yeah, that's a horrible thing to have, which just happens to work.
> However the Androidoverlords are likely unhappy no matter what we
> do. At one of my phones it does NOT work at all.
Sorry, what I am pointing out is that we don't have the substitution
for it in our build system so this does nothing.
Maybe I don't understand your remark.
A far as I can see, this File ends up as a ProxySetting.java with a
"package @PACKAGENAMEDOT@;" prepended. If missing, the webview part
should not even compile.
What am I missing?
|
Am Sun, 29 Nov 2020 10:56:38 -0800
schrieb Matthias Görges <[email protected]>:
> Right now it is. But it _should_ be _"just a matter of work to be
> done"_ to make _webkit_ render on openGL .
Don't we already have a webview that works for iOS?
I don't know about iOS.
For Linux&Windows at least an external Browser is started.
|
Am Sun, 29 Nov 2020 10:52:45 -0800
schrieb Matthias Görges <[email protected]>:
> While I can't really follow the motivation behind the rename, I'm
> not held back with the consequences.
It was internally consistent to name it as all ln-functions were of
the ln_xxx way.
> As you changed a lot of whitespace in between [...] (If you only
> had this done step-by-step!!)
This was already a ton of work and you also didn't break them into
single commit. As we discussed there was no way to merge 27 commits
which touched a bunch of unrelated files due to the strange rebase.
Due to the recent "discovery" that `onCreate()` may run several times
during the lifetime of a process, I wanted to go back and double check
what the effect on this code would be.
I knew that the whole pull request became a bit stale already due to
the rebase on top of modified merges. The idea was to try a squash
commit. But those things take time.
> removed the language and comments controlling syntax highlighting
> and whitespace policy (similarly) [...]
Polluting every file with this Emacs thing (at inconsistent places)
is super annoying; either find a global setting or some other way to
do this.
Hm, how do you guys do this? How do you specify the syntax mode etc.
for files like ANDROID_java_whateverDotNothing?
We use Eclipse or vim. I am also worried that this will
break things in the Android substitution.
I'm no fan of editor wars. That's for the young. After a few years an
editor is sticky and the fingers. Automated. After 30 years - hardly
any other editor can ever compete.
I don't mind you using other editors. I would not mind to have such
tags for other editors in the source too. Just don't try to sell it to
me. I tried Eclipse a decade ago. Too slow, too much mouse grabbing.
Since my eyesight weakened, I'm really depending on syntax
highlighting to work, automatic code reformatting to stick enforce
traditional rules, git tagging trailing whitespace with a big red flag
etc.
What **always** surprises me is to meet people who code LISP (Scheme)
and have not yet figured out how much emacs make thing easier and
automatic.
> It will take time to get a working environment back.
This is surprising as I merged all the files you changed. So not sure
why it is now broken on your side?
I have absolutely no idea what's broken.
I guess it's two or three single small things.
Some apps (among them, the main "test" app) don't start at all. One
starts and seems to freeze -- until I press the back button, at which
point it starts to render and shows it's been working all time.
Some functionality just does not work - webview at least no longer
starts within my main app.
And the foreground process indicator does not come up, or at least is
no longer up once the app does not cover the status line anymore.
:-/
Edited to add: some of the comments, which are gone now, where comments indicating begin, end and source of files included during the substitution process. Those where added to ease navigation and linking back from the merged file to the sources - I bet those would have been helpful regardless of the editor in use.
|
I guess this is simply a confusion of my part, as all other things like |
modules/hybridapp/hybridapp.scm does this via defining |
Sorry, but I feel really compelled to add one more remark wrt. readabilty of the source. One, which I do well understand that it might not be obvious to people still having full vision: People like me can not distinguish between one or two white spaces, on or two brackets. Hardly be sure what kind of brackets they are looking at (and hence will never attempt to count them). The worst one can do to them is something like
This could be anything for me. I could not tell it apart from If you want to be able to read your code when aged, just *never have adjacent braces of different associativity (left/right) without intervening space. |
Fine, I added those back in commit 7817106, but then to be consistent they all need end tags too? |
Am Mon, 30 Nov 2020 02:30:46 -0800
schrieb Matthias Görges <[email protected]>:
> Edited to add: some of the comments, which are gone now, where
> comments indicating begin, end and source of files included during
> the substitution process. Those where added to ease navigation and
> linking back from the merged file to the sources - I bet those
> would have been helpful regardless of the editor in use.
Fine, I added those back in commit 7817106, but then to be consistent
they all need end tags too?
For consistency: yes.
|
commit cc553af Merge: 7c61dd9 c58528f Author: Jörg F. Wittenberger <[email protected]> Date: Sun Nov 29 15:41:58 2020 +0100 Merge branch 'merge-upstream-silly-rename-of-lnjscheme-to-ln_jscheme' of ssh://github.com/0-8-15/lambdanative into development commit c58528f Merge: 54bc984 51dfeed Author: Jörg F. Wittenberger <[email protected]> Date: Sun Nov 29 15:35:38 2020 +0100 Merge branch 'master' of https://github.com/part-cw/lambdanative into merge-upstream-silly-rename-of-lnjscheme-to-ln_jscheme commit 51dfeed Author: Peter Lewis <[email protected]> Date: Fri Nov 27 11:57:52 2020 -0800 ANDROID: request permissions from Manifest This reads permissions from the manifest and requests all that are needed. Apps and modules should add necessary permissions to ANDROID_xml_permissions. Moved the initial setContentView back to before @ANDROID_JAVA_ONCREATE@ so that apps can set a content view in ANDROID_java_oncreate commit 1e4c9f3 Author: 0-8-15 <[email protected]> Date: Thu Nov 26 22:25:11 2020 -0800 WEBVIEW: Add another webview - ANDROID only! (part-cw#387) Moved the 'webview' script from DemoAndroidLNjScheme into a module of its own; this module is a bit of a stub. Might receive updates to become a nicer looking browser. Meanwhile still intended to showcase how to call Java via jScheme commit 1cbc09b Author: 0-8-15 <[email protected]> Date: Thu Nov 26 22:14:54 2020 -0800 LN_JSCHEME: New module to call any Android API without JNI (part-cw#387) Moves LNjScheme from DemoAndroidLNjScheme to its own module. Also updates DemoAndroidLNjScheme to use of ln_jscheme and webview commit 7e6fcb3 Author: 0-8-15 <[email protected]> Date: Thu Nov 26 21:25:10 2020 -0800 EVENTLOOP: Add support for a new jScheme related event (part-cw#387) Allocates a single event number (126) and dispatches it to a possibly registered receiver - or is ignored as before. commit 20b33a1 Author: 0-8-15 <[email protected]> Date: Thu Nov 26 01:38:46 2020 -0800 ANDROID: Fix rendering freeze upon startup commit 7c61dd9 Author: Jörg F. Wittenberger <[email protected]> Date: Tue Nov 24 20:07:56 2020 +0100 NATIVE-KEYPAD+ANDROID: more error checking in JNI commit 9d8e809 Author: Jörg F. Wittenberger <[email protected]> Date: Tue Nov 24 14:20:44 2020 +0100 ANDROID: fix rendering freeze upon startup commit c77a547 Author: Jörg F. Wittenberger <[email protected]> Date: Tue Nov 24 12:58:39 2020 +0100 ANDROID: try harder to handle onStop and onPause Note: This is at the moment meant for evaluation. Works for me, can't break it. However if this is going to be the final call, those file names ANDROID_java_oncreate are no longer telling exactly where the code ends up. That's bad, bnut renaming them is likely even worse. commit c351669 Merge: 6e0c757 8d0d7ed Author: Jörg F. Wittenberger <[email protected]> Date: Tue Nov 24 12:57:32 2020 +0100 Merge branch 'stable-0815' of ssh://github.com/0-8-15/lambdanative into development commit 6e0c757 Author: Jörg F. Wittenberger <[email protected]> Date: Mon Nov 23 21:43:02 2020 +0100 LNjSCHEME: revert change breaking things commit 865b6c7 Author: Jörg F. Wittenberger <[email protected]> Date: Mon Nov 23 21:24:30 2020 +0100 LNjSCHEME: make initialization once only Also move ANDROID_xml_permissions to webview, where they belong. commit 603d630 Author: Jörg F. Wittenberger <[email protected]> Date: Mon Nov 23 20:54:57 2020 +0100 ANDROID: make mGLView static and initialization once only This appears to be the correct way and seems to actually solve the issue observed and not fixed by da86a5160 ff. commit fa19aa9 Author: Jörg F. Wittenberger <[email protected]> Date: Mon Nov 23 19:20:12 2020 +0100 JNI: conservative coding - #defines LAMBDANATIVE_JNI_VERSION to JNI_VERSION_1_4 - uses `jint` as if it was an opaque type - checks via GetEnv before attaching a thread (there are claims on the Internet that this may save some overhead) - use AttachCurrentThreadAsDaemon instead of AttachCurrentThread for gut feeling commit 70752a2 Author: Jörg F. Wittenberger <[email protected]> Date: Sun Nov 22 16:56:37 2020 +0100 JNI: be careful to free local references commit 34ccd0d Author: Jörg F. Wittenberger <[email protected]> Date: Sun Nov 22 13:01:30 2020 +0100 ANDROID: use systemapp directry commit 270193a Author: Jörg F. Wittenberger <[email protected]> Date: Sun Nov 22 12:58:40 2020 +0100 ANDROID: do not call ReleaseStringUTFChars with an unrelated pointer commit c752898 Author: Jörg F. Wittenberger <[email protected]> Date: Sat Nov 21 14:26:16 2020 +0100 ANDROID: error out when build requires to write system directories commit d3dd374 Author: Jörg F. Wittenberger <[email protected]> Date: Sat Nov 21 13:43:05 2020 +0100 BACKPORT: use upstreams version of camera commit 5b9a30f Author: Jörg F. Wittenberger <[email protected]> Date: Sat Nov 21 13:12:00 2020 +0100 remove old debug code commit c48c7b1 Author: Jörg F. Wittenberger <[email protected]> Date: Sat Nov 21 13:04:21 2020 +0100 CLIPBOARD: fix compiler complaints warning: returning 'const char *' from a function with result type 'char *' discards qualifiers commit cd86684 Author: Jörg F. Wittenberger <[email protected]> Date: Sat Nov 21 12:38:46 2020 +0100 20201121: Snapshot, preserve possibly important debug state commit 5f82a22 Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 19:43:56 2020 +0100 GLGUI: 20201120; Snapshot: alternative implementation - active for a while commit b555356 Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 20:58:24 2020 +0100 ANDROID: verbose signing commit 0a58fa3 Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 20:55:19 2020 +0100 outdated: srfi-179 port commit b4dac9a Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 20:53:15 2020 +0100 CORE: flow/fix-issue related changes commit ddaa1db Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 19:42:19 2020 +0100 CORE: flow/fix-issue related changes commit 985ddd5 Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 19:34:57 2020 +0100 CORE: better version of make-list commit e72c158 Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 19:11:35 2020 +0100 TENTATIVE: config: commented out - should become debug option commit 41d480b Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 19:10:35 2020 +0100 ANDROID: keep checking for API 26 break commit 0186693 Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 19:07:16 2020 +0100 ANDROID: support install of additional dynamic libraries commit a54d93a Author: Jörg F. Wittenberger <[email protected]> Date: Fri Nov 20 19:02:34 2020 +0100 ANDROID: keep TODO comment
This depends on #386
Any not-so-time-critical Android API/Java Method - except those
restricted Android itself may be called without adding JNI code.