Description
I have searched and made sure there are no existing issues for the issue I am filing
- I have searched the existing issues
URL
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.
document.cookie='cookieName=value; path=/non-existing-page; SameSite=Strict';
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:
Ti.Network.getSystemCookies('www.RemoteDomain.com','/not-existing-page','cookieName');
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:
Ti.Network.createCookie({ ... })
(But this functionality has not been tested at the moment.)
More advanced IPC techniques could be implemented opening a Socket on localhost using:
Titanium.Network.Socket.createTCP({ ... })
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).