Closed r10s closed 2 years ago
the issue seems to be that window.innerWidth
is not always set when onLoad is called, so it is either 0
or the correct width.
@adbenitez wrote a little test.xdc:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="webxdc.js"></script>
</head>
<body>
<button onclick="sendMsg('manually'); return false;">Test</button>
<p id="output"></p>
<script>
function sendMsg(tag) {
const msg = tag + ": window.innerWidth == " + window.innerWidth;
window.webxdc.sendUpdate({payload: {name: window.webxdc.selfName(), msg: msg}}, msg);
}
function receiveUpdate(update) {
document.getElementById('output').innerHTML += "<strong><" + update.payload.name + "></strong> " + update.payload.msg + "<br>";
}
window.webxdc.setUpdateListener(receiveUpdate);
window.webxdc.getAllUpdates().forEach(receiveUpdate);
window.addEventListener("load", () => sendMsg("onLoad"));
</script>
</body>
</html>
the output of this xdc is mixed:
while both testers in the screenshot have 0
as the first value, iirc, @adbenitez also reported to get correct width first and 0
later - so that is probably not related to some caching as we suspected when working on https://github.com/deltachat/deltachat-android/issues/2204 - (caching could have been fixed by adding a random number to the domain in #2204)
at least, the issue seems to be not unknown in other contextes: https://stackoverflow.com/questions/28402100/wrong-value-for-window-innerwidth-during-onload-event-in-firefox-for-android
this seems to be fixed by the switch to https://
scheme
this seems to be fixed by the switch to https:// scheme
wow! that's great - and pretty much unexpected.
however, i've also not seen that bug recently, however, without much thinking about it :)
then let's close this :)
in dev chat, with the "fairx.xdc", it makes a difference if the WebView is quit and reopened again or if the app is restarted before reopening.
this should not happen, however, it is not confirmed yet that the WebView as such is the issue - there is also the issue that "triska.xdc" is sometimes rendered too wide, maybe this is related somehow. or, getAllUpdates() does not return the same things.
whatever, that needs some investigations.