-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: Two unreported remote WebView non-freezing IPC techniques #14071
Comments
Not sure if I can follow you here. It sounds more like a implementation issue. I was using krpano webviews in older projects without an issue. Why and how often are you running evalJS? Did you try the event system? In my projects I use the web page inside the webview for all interactions. |
It may be an evalJS limitation given by the implementation on Android remote WebView (on iOS and on local Android WebView is ok). PS: Yes, I am working with panorama viewers, but not KRPano. I made an easy Titanium porting of an open source one you can find on GitHub to work in a local WebView. |
This is the code by ChatGPT for the first use case:
|
function createIntervalTimers(cookieValue, remoteDomain, remotePage) {
} // Funzione per settare il cookie in Titanium // Funzione per leggere il cookie nella WebView usando evalJS // Esempio di chiamata della funzione // Esempio di impostazione del cookie in Titanium // Esempio di lettura del cookie nella WebView |
This is a very specific case and also the code that is generated is not that good. I would prefer a hand made example to show this if any. I'm not sure if we really need something like this in the docs as we already have cookie read example in the remote view section: https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_How-tos/Integrating_Web_Content/Communication_Between_WebViews_and_Titanium.html#remote-web-content Those should be enough for a user to implement something like this in their apps. The panorama project I did was 2015-2016, can't remember what I did there 😄 But I think it was with https://github.com/tidev/titanium-socketio as we had multiple Samsung Gear VR devices to see some panoramas and a presenter device that was seeing in wich direction each of the devices was looking and could send different panoramas to each Gear VR phone. We had a small network hub where all devices where connected to and constantly firing the position. |
This could be where I got the cookie idea from! Seeing the beautiful and very large collection of different modules of the highest level, perhaps it would be useful then to include a list in the guide, with a small description of the modules that are considered to be of the highest level, with a link to the related GitHub. |
I have one more question, I am not going to open a new issues as is just logging... but I see errors for the web view on Android: I am clearing the cookies with Ti.Network.removeAllSystemCookies on startup, and I see: chromium: [0701/160646.211974:ERROR:variations_seed_loader.cc(37)] Seed missing signature. Later opening a local web view I see: [ERROR] chromium: [ERROR:simple_file_enumerator.cc(21)] opendir /data/user/0/[ ... YOUR APP ID ... ]/cache/WebView/Default/HTTP Cache/Code Cache/js: No such file or directory (2) |
Don't think it is a Titanium issue as other frameworks have the same output:
do you have any issues with your webview or was it just a question about the log itself? Android is logging many many things that can be ignored (especially maps are very noisy!). |
Hi, I have another little doubt: |
That I can't tell you but my guess would be that sending gyro constantly form the webview to the app will queue up but I think it is super easy to fix when you just remove the event listener or add a boolean variable that won't compute the gyro events when its closed/false. Or even reduce the events that you are sending (smoothing out the gyro) in the webview might also help. |
I have searched and made sure there are no existing issues for the issue I am filing
URL
https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_How-tos/Integrating_Web_Content/Communication_Between_WebViews_and_Titanium.html
Description
The IPC (Inter Process Communication) technique to be used with remote WebView explained in the guide is limited to the evalJS method.
Unfortunately, this method causes freezes in the smoothness of the WebView (only on remote Android WebViews), which are especially visible in the presence of 3D animations made with WebGL (approx 50ms freeze for each evalJS call).
To remedy this problem there is another IPC technique available on Android, but it is no longer listed in the guide, perhaps it used to be.
Indeed, on Android it is possible to use an ephemeral cookie in order to exfiltrate data from the WebView without the problem of fluidity freezes caused by evalJS.
To do this it is sufficient to place the data to be exfiltrated in a session cookie (thus without specifying an expiration date), additionally to make it an even more ephemeral cookie we can also place the cookie in a page that does not exist in the remote domain, and additionally add (at creation) the said page to the blacklist of pages not viewable by the WebView, via the "blockedURLs" attribute.
To set the cookie in case we do not have direct access to the remote code, we can always take advantage of evalJS, for example by inserting an interval timer, which does the work for us from within the remote page.
Optionally we set SameSite to Strict, but we do not enter any expiration to have a session cookie that will be anyway deleted when we close the App (or WebView?).
At this point we can read the Cookie value, that is, the data we wanted to exfiltrate, using:
The main shortcoming of this technique is that there is no clear method for signaling when the data is ready; on the other hand, a very smooth execution of the WebView is guaranteed. Be careful that the data is also transferred with some acceptable delay to the app.
If the page that does not exist is not invoked by the WebView, the cookie should remain ephemeral, since it was never sent over the network. (However, the actual ephemerality of the cookie has not been thoroughly tested in practice).
Symmetrically an IPC connection in the other direction could be generated using:
(But this functionality has not been tested at the moment.)
More advanced IPC techniques could be implemented opening a Socket on localhost using:
paired with XMLHttpRequest, Fetch or a WebSocket on the WebView remote page side (ChatGPT could easily code this for you).
However the cookies based rudimentary technique fully met my requirements of non freezing WebGL.
Suggestion
Report also this two useful IPC techniques in the guide (especially useful to avoid freezing WebGL animations).
The text was updated successfully, but these errors were encountered: