I came across an issue with KMP where I have a simple coroutine in a kotlin file. As simple as
GlobalScope.launch) {
repeat(5){
delay(2000)
println("TEST $it")
}
}
When Using KMP to generate a JS file. This JS is then executed on IOS simulator inside a webview and it seems to work fine and runs the coroutine. But when I try to run the same JS file inside of a webview on physical IOS device (IPhone 17.5.0) it only runs once and then stops. Also, On physical IOS device If I run the same script on safari it works, Only when this script is launched in a webview inside of an app it doesnt work. I cannot see any crashes or so, It just runs once and stops. Even without a repeat if i just call
GlobalScope.launch{
delay(2000)
println("Test 1")
delay(2000)
println("Test 2")
}
This still only runs once on physical IOS device.
Some help would be brilliant.
1 more thing On physical iPhone if I copy generated .js file to iOS project and compile, run in webview it actually works fine.
Issue comes if I inject this JS during runtime. I have tried with CoroutineScope with different dispatchers and issue still exists.