Open walseb opened 1 year ago
I have the same problem.
For some reason if I remove prerender line https://github.com/obsidiansystems/obelisk/blob/master/skeleton/frontend/src/Frontend.hs#L42-L45:
prerender_ blank $ liftJSM $ void
$ jsg ("window" :: T.Text)
^. js ("skeleton_lib" :: T.Text)
^. js1 ("log" :: T.Text) ("Hello, World!" :: T.Text)
from my project then deployed application seems to work as expected (picture is rendered normally and aplication starts normally every time). I still see the same failing message as you have posted though.
Thank you so much! I will try that.
As a side note, how well-developed is Android and IOS development using Reflex/Obelisk in your experience?
I have searched, but haven't found much information about it besides the mention in the readme.
I'm slightly concerned by this as I'm thinking of developing applications of medium complexity, things like basic progress tracking apps. It needs features such as storing basic data in local storage.
Thanks!
As a side note, how well-developed is Android and IOS development using Reflex/Obelisk in your experience?
This is what I am also interested in. My experience with reflex/obelix was toying around last few years and it worked as expected in web. Unfortunatelly I was not successfull with mobile dev until few days ago (and I have never deployed anything on android/ios before so don't know much about developing for this platform). Before that I would try to follow instructions and if it didn't work out from first try I would give up (as I don't know much about mobile dev). Now I actually successfully deployed working scafolding app following their instructions (minus commented out the line above https://github.com/akegalj/obelisk-template/blob/ad01b658efe5d4e968bac1eefc00380c07d6bc86/frontend/src/Frontend.hs#L40 ) and that gives signal to dive deeper.
I have searched, but haven't found much information about it besides the mention in the readme.
Yes, I also couldnt find resources about mobile dev with reflex
I'm slightly concerned by this as I'm thinking of developing applications of medium complexity, things like basic progress tracking apps. It needs features such as storing basic data in local storage.
I think this should be doable but as I am in the process of figurint thigs out I can't say much about is interfacing with js working as expected. I know reflex-dom is using jsaddle as a layer for interfacing with js (and alternitively running code natively in haskell). For example i am trying to implement some game in obelix/reflex so I wanted to listen to requestAnimationFrame
from js (https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame). My attempt was https://github.com/akegalj/obelisk-template/commit/ffbf815a847d12f6b1db3764a45a95b57d207a34#diff-0b45c1ec1fb8fa7eab3b4b2209e06c10a3182b0ebc49c6c8fd796ce73fa1b4d6R46-R54 which fires an event every time browser is ready to render a page. How many times event has fired is counted and displayed on page https://github.com/akegalj/obelisk-template/commit/ffbf815a847d12f6b1db3764a45a95b57d207a34#diff-0b45c1ec1fb8fa7eab3b4b2209e06c10a3182b0ebc49c6c8fd796ce73fa1b4d6R35 .
If prerender_
line is active, then everything is working when app is run with ob run
(this is using jsaddle to talk to haskell interpreter). It even works ok if I try to compile to js and run locally as explained here https://github.com/obsidiansystems/obelisk#locally . But when I build it and deploy on android using https://github.com/obsidiansystems/obelisk#android it either shows white screen, or partially starts (no image, counter not increasing). I am still trying to figure out what's the reason but it seems prerender_
is the reason and this is the part where I am interfacing with js. (you will probably have to interface with js for localstorage)
Hopefully this will be usefull to someone
Thank you so much for the information!
I tried it just now and after removing the line relating to prerender
, the skeleton app works perfectly, although I do eventually need to use prerender
.
Note that I just tried prerender
:
prerender_ blank $ el "h1" $ text "this is prerendered"
and it works as expected on android.
As previously tried:
prerender_ blank $ liftJSM $ void
$ jsg ("window" :: T.Text)
^. js ("skeleton_lib" :: T.Text)
^. js1 ("log" :: T.Text) ("Hello, World!" :: T.Text)
this didn't work on android. So it seems something is wront with liftJSM
part where I interface with js. I'll try next directly FFI with js instead of using jsaddle as above.
I managed to get it working on android as well with:
dpb <- getPostBuild >>= delay 0.1
prerender_ blank $ performEvent_ $ ffor dpb $ \_ -> liftJSM $ void
$ jsg ("window" :: T.Text)
^. js ("skeleton_lib" :: T.Text)
^. js1 ("log" :: T.Text) ("Hello, World!" :: T.Text)
I accidentally found similar answer somewhere on the web so tried it and it works on androd as well now. If signal is not delayed a bit it won't trigger (for unknown reason) - but now this works on both web and android
EDIT: I saw a hint to the answer here https://www.reddit.com/r/reflexfrp/comments/x928ci/comment/inocsqm/?embed_host_url=https%3A%2F%2Fpublish.reddit.com%2Fembed%3Futm_source%3Dembedv2&embed_host_url=https%3A%2F%2Fpublish.reddit.com%2Fembed
EDIT2: This is an example of a working app for web and for android https://github.com/akegalj/obelisk-template/tree/a5836362873b223d555f1ed60e776b5380cef0fe @walseb . Everything works on my side and I think obelix should be good for your use case.You can easily interface with js side (as shown in this example) and everythin seems to be working (including prerenderer)
That's excellent! Thank you so much for finding the solution!
As an update on the original issue, I noticed that I get the following message now before I get the net.rubygrapefruit.platform.NativeException
error posted above:
...
/nix/store/cxxsqdgm33r5yjqzw2996yr501djzdqb-ndk-toolchain-binutils/bin/aarch64-unknown-linux-android-ar: libz.so.1: cannot open shared object file: No such file or directory
/nix/store/cxxsqdgm33r5yjqzw2996yr501djzdqb-ndk-toolchain-binutils/bin/aarch64-unknown-linux-android-ranlib: libz.so.1: cannot open shared object file: No such file or directory
/nix/store/cxxsqdgm33r5yjqzw2996yr501djzdqb-ndk-toolchain-binutils/bin/aarch64-unknown-linux-android-ranlib: libz.so.1: cannot open shared object file: No such file or directory
/nix/store/cxxsqdgm33r5yjqzw2996yr501djzdqb-ndk-toolchain-binutils/bin/aarch64-unknown-linux-android-ranlib: libz.so.1: cannot open shared object file: No such file or directory
... (last message repeated hundereds of times)
Preprocessing executable 'libfrontend.so' for frontend-0.1..
Building executable 'libfrontend.so' for frontend-0.1..
[1 of 1] Compiling Main ( src-bin/main.hs, dist/build/libfrontend.so/libfrontend.so-tmp/Main.o )
....
The app is going along nicely after the fix @akegalj suggested, although I'm surprised by how strange the WebView renderer is. The CSS styling is applied entirely differently from Chromium, Firefox, or a WebKit browser like Surf, even though my CSS passes the W3C validation test. I also had some issues with inline JavaScript.
Has anyone had similar experiences?
I see the same error on my side as well. I thought it was missing zlib
somewhere so I have tried to pull that dependency in with nix-shell -p zlib ...
but that didn't help. I didn't invest much time into figuring that one out as it seems it works even when that error is reported. It might be the case that this should be labeled as warning.
About webview... I am still playing around with logic in reflex and some light interfacing with js, so didn't add much css to notice that but here are some relevant discussions:
Anyway, I don't have any experience with webview so this is a guess but it seems it behaves a bit differently than desktop browser/chrome. From these old answers it also seems webview can be configured in a different way (which I guess is done somewhere) to behave differently (maybe one way is to load produced apk to android studio and find relevant stuff there). One answer said that webview is a different browser and should expect different layout/style but that seems strange in 2023 and I hope is outdated.
Thank you for the links!
I spent a few hours fixing the many issues I had with WebView the other day through trial and error.
It seems like it doesn't support inline SVGs, can't display iFrames of local pages by setting the source as a reflex route URL (via askRouteToUrl. When I try it, it works fine in the browser but on android it just says that the resource is not available), and seem to have some built in CSS, unless it's my JavaScript apps that has some custom code for running on android somehow.
Perhaps it would be possible to display an iFrame of a local page on android if inserted the HTML manually, that would mean I need a function that could turn generated DOM into a string (DomBuilder t m => m () -> m (Text)), but I haven't found a function like that.
Other than that I'm happy with Reflex, especially the typed routing that Obelisk provides. But I hope I don't run into similar problems when I finally compile to IOS.
Ante Kegalj @.***> writes:
I see the same error on my side as well. I thought it was missing
zlib
somewhere so I have tried to pull that dependency in withnix-shell -p zlib ...
but that didn't help. I didn't invest much time into figuring that one out as it seems it works even when that error is reported. It might be the case that this should be labeled as warning.About webview... I am still playing around with logic in reflex and some light interfacing with js, so didn't add much css to notice that but here are some relevant discussions:
- https://stackoverflow.com/questions/41952513/html-gets-rendered-differently-in-webview-and-desktop-browser
- https://stackoverflow.com/questions/51776587/android-webview-rendering-looks-different-to-chrome
- https://stackoverflow.com/questions/3595013/android-webview-completely-disrespecting-ui-layout?rq=3
- https://stackoverflow.com/questions/8273198/webview-does-not-render-css-like-the-browser-does?rq=3
Anyway, I don't have any experience with webview so this is a guess but it seems it behaves a bit differently than desktop browser/chrome. From these old answers it also seems webview can be configured in a different way (which I guess is done somewhere) to behave differently (maybe one way is to load produced apk to android studio and find relevant stuff there). One answer said that webview is a different browser and should expect different layout/style but that seems strange in 2023 and I hope is outdated.
-- Reply to this email directly or view it on GitHub: https://github.com/obsidiansystems/obelisk/issues/1050#issuecomment-1756861365 You are receiving this because you were mentioned.
Message ID: @.***>
It seems like it doesn't support inline SVGs, can't display iFrames of local pages by setting the source as a reflex route URL (via askRouteToUrl. When I try it, it works fine in the browser but on android it just says that the resource is not available), and seem to have some built in CSS, unless it's my JavaScript apps that has some custom code for running on android somehow.
SVGs ought to work. Are they working in the browser but not in the webview? Are you setting the namespace properly? It might be worth using a helper library like reflex-dom-svg.
Perhaps it would be possible to display an iFrame of a local page on android if inserted the HTML manually, that would mean I need a function that could turn generated DOM into a string (DomBuilder t m => m () -> m (Text)), but I haven't found a function like that.
You may be looking for renderStatic
Thank you for replying!
SVGs ought to work. Are they working in the browser but not in the webview? Are you setting the namespace properly? It might be worth using a helper library like reflex-dom-svg.
I see, I just entered the SVG manually into the HTML, I will try that package in the future.
You may be looking for renderStatic
Thank you! That might work, I will try it in the future.
Hello!
When I try to build the example app using the steps detailed in the README, I get the following error:
Unable to watch the file system for changes net.rubygrapefruit.platform.NativeException: Could not query file systems: could not open mount file (errno 2: No such file or directory)
The .apk is still produced, but some functionality appears to not be working after installing it. For instance the image doesn't render, and after restarting the app nothing appears to render.
Here's the relevant parts of the log: