IOS WKView, javascript alerts, console.log, forge log broken?

setup:
Forge: 2.8.4
Module: platform

html:




Title

<script>
	
    
    setTimeout(function(){console.log('timeout 1 seconds')},1000)
    setTimeout(function(){console.log('timeout 5 seconds')},5000)
    setTimeout(function(){console.log('timeout 10 seconds')},10000)
    setTimeout(function(){console.log('timeout 15 seconds')},15000)
    forge.logging.log('test');

//Try and update Dom
document.getElementById("demo").innerHTML = "change1";
setTimeout(function(){
	document.getElementById("demo").innerHTML = "5 seconds";
},5000)

setTimeout(function(){
	document.getElementById("demo").innerHTML = "10 seconds";
},10000)

setTimeout(function(){
	document.getElementById("demo").innerHTML = "15 seconds";
},15000)
setTimeout(function(){
    document.getElementById("demo").innerHTML = "20 seconds";
},20000)

</script>

<body>
body
<div id="demo">
 demo content
 </div>

</body>
</html>

Config JSON

{

“config_version”: “4”,
“name”: “linkTest”,
“author”: “na”,
“version”: “0.1”,
“platform_version”: “v2.8.4”,
“description”: “An empty app created by default”,
“core”: {
“general”: {
“logging”: {
“level”: “DEBUG”
},
“reload”: true
},
“ios”: {
“webview”: “WKWebView”,
“package_name”: “com.app”
}
},
“modules”: {
“platform”: {
“version”: “2.3”
}
},
“flags”: {
“ios_force_wkwebview”: true
}
}

So this is an odd one but I am doing some testing and have noticed a few things

  1. Javascript alerts dont seem to work, looking online it appears you need to set a WKUIDelegate tag?
    https://stackoverflow.com/questions/26898941/ios-wkwebview-not-showing-javascript-alert-dialog

1a) Also, to a certain degree console.log does not seem to be working as well. I have tried both safari console (web inspector, seem to be junk and displays nothing [using mac os 10.15.1] ) and catalyst and nothing seems to come back, or I should say, some items come back but only when there is an excessive timeout ( 20 seconds ) do I actually get results it seems

  1. I have noticed, that some items are taking longer to run, more specifically the platform ( this is just from what I have tested but there could be other)

  2. Forge output log on IOS does not work, it always tried to open the app and then just hangs at debug service and never display any information after app has been installed. I then have to unplug the device and open it to get it to work, otherwise it hangs at splash screen. (then if I plug it back in, forge tries to re-install the app if the build screen is still open) the debug just says ‘connect, run, autoexit’

This is just my initial testing

New, blank project with 1 module (platform)

I have created a fiddle with the html code here

https://jsfiddle.net/6qL9vmtu/

This runs as expected but the same code in app does not run.

Sorry if things a re a bit out of order, I’m trying to compile as much as I can so it a bit out of sorts but this is becoming a bit frustrating because It’s near impossible to even test on IOS. Safari console just seems to be getting worse with each release, forge does not seems to work and catalyst is a bit unreliable.

console.log / doing tests at app startup:

WKWebView has progressively being getting quite strict about refusing to execute arbitrary startup code in the global scope.

Can you try adding your tests to a DOMContentLoaded event or JQuery $(document).ready() handler:

document.addEventListener("DOMContentLoaded", function(event) {
    // do things at startup
});

// OR

$(document).ready(function () {
    // do things at startup
});

forge.logging

I’m not seeing issues with forge.logging.* on our side. Are you running your app from the console with forge run ios or are you going via the Trigger Toolkit UI? Generally I’d avoid the Trigger Toolkit as it is no longer maintained and is in the process of being deprecated in favour of a purely command-line driven interface:

https://community.trigger.io/t/new-feature-forge-command-line-tools-are-now-available-via-npm/1025/2

iOS debugging in general

I’ve also noticed things haven’t been great in the last few iOS releases:

  • Apps are taking an inordinately long time to start up the first time they are run after installation.
  • Often have to plug/unplug devices and reboot machines to get things to start working again.
  • Safari web debugging is hit/miss, even odds whether a device will even show up in the Develop menu.

Most of it seems to center around Apple’s frequent re-shuffling of their lldb fork.

alert()

Thank you for the report on alert() - we’ll look at it for the next platform release!