https://kotlinlang.org logo
#korge
Title
# korge
c

Carl Bateman

09/30/2021, 8:29 AM
I have downloaded the basic KorGE demo scene, and ran into an issue: if I create more than two images and added a filter to each of them, the app crashes almost immediately on mobile. Doesn't matter the filter (whether it's a blur, an Identity Filter, whatever) or the size of the image. On JVM, it seems to be working properly and smoothly, but running on mobile it simply crashes. The error I'm getting is
Copy code
Fatal signal 11 (SIGSEGV) at 0x42a637d9 (code=1)
Seems like some sort of concurrency issue. Having a class that runs glFinish() on every render pass mitigates the problem to a certain point (up to 8 to 10 images), but even with small amount of images and running a very simple filter, the FPS drops to about 8 or 9.
d

Deactivated User

09/30/2021, 8:43 AM
Can you share the code? It is an emulator or a real device? By mobile means android or ios (they are pretty different versions)? Which operating system/version? In general all the info you can provide to reproduce the problem on our side will be appreciated
m

Mayank

09/30/2021, 10:50 AM
I’m facing a similar issue when trying to run filters sample in korge-next repo. It crashes on JVM and native but works fine on JS • Device: MacBook Pro (16-inch, 2019) • OS: macOS Big Sur version 11.5.2 • Java: openjdk version 11.0.11 Attaching stacktraces for Java and native
d

Deactivated User

09/30/2021, 11:33 AM
Oh fu. Ill check. Are you running it in korge-samples? Or enabling the samples in korge-next by modifying the settings.gradle?
👍 1
c

Carl Bateman

09/30/2021, 12:47 PM
I'm running it on a Xiaomi Mi 9T, Android 10 QKQ1.190825.002, haven't tried it on iOS.
m

Mayank

09/30/2021, 12:50 PM
The later one, by enabling it on korge-next
c

Carl Bateman

09/30/2021, 12:56 PM
this is my code running the commonTest/kotlin/main.kt:
Copy code
import com.soywiz.klock.*
import com.soywiz.korge.*
import com.soywiz.korge.tween.*
import com.soywiz.korge.view.*
import com.soywiz.korge.view.filter.BlurFilter
import com.soywiz.korge.view.filter.IdentityFilter
import com.soywiz.korim.color.*
import com.soywiz.korim.format.*
import com.soywiz.korio.file.std.*
import com.soywiz.korma.geom.*
import com.soywiz.korma.interpolation.*

suspend fun main() = Korge(width = 512, height = 512, bgcolor = Colors["#2b2b2b"]) {

   var iter = 0
   repeat(3, {
      val image = image(resourcesVfs["korge.png"].readBitmap()) {
         rotation = 0.degrees
         anchor(.5, .5)
         scale(0.1)
         position(256, 30 * iter)
      }
   })

// while (true) {
//    image.tween(image::rotation[minDegrees], time = 1.seconds, easing = Easing.EASE_IN_OUT)
//    image.tween(image::rotation[maxDegrees], time = 1.seconds, easing = Easing.EASE_IN_OUT)
// }
}
oh, and it's a real device, not emulator
d

Deactivated User

09/30/2021, 2:57 PM
Thanks for the context Mayank and Carl! Sure it helps. I will try to reproduce it myself
🙏 1
👍 1
s

Sahil Bajaj

10/06/2021, 5:43 PM
@Deactivated User any clues on this one?
d

Deactivated User

10/06/2021, 6:27 PM
I have annotated to look at this, I was able to reproduce ir, but hadnt have much time on the mac box to check it. But it is on my radar so I will check asap
s

Sahil Bajaj

10/09/2021, 5:24 AM
Btw, we tried to dive a little bit into it.. We realised that when we do a batch.flush() followed by a glFinish() in the Filter's render() method, the issue gets fixed.
but of course, the fps drops a lot..
d

Deactivated User

10/09/2021, 11:49 AM
I was able to reproduce it in a new macbook pro but doesnt reproduce on an older imac. It seems to be a bug in the gpu driver or something. Cant reproduce it either in linux or windows
Im still trying to figure out the exact cause to see if we can circumvent it
s

Sahil Bajaj

10/09/2021, 12:03 PM
We're developing for the iOS and Android.. Can definitely reproduce it on Android. GL ES3.0
d

Deactivated User

10/09/2021, 5:39 PM
glFlush instead of glFinish, helps?
Copy code
val bitmap = resourcesVfs["korge.png"].readBitmap()
val blur = BlurFilter(initialRadius = 0.0)
image(bitmap).also { it.filter = blur }
timeout(40.milliseconds) { blur.radius = 1.0 }
this reproduces the issue in a macbook with a Radeon Pro 5300M
gl finishing doesn’t fixes the issue here in my case
managed to fix it on the mac
can you check if this commit fixes the android issue too? https://github.com/korlibs/korge-next/commit/559ef4e7519b33001d7c7cfc4d6ba783de98d947
👍 1
m

Mayank

10/10/2021, 3:15 PM
I tried running the sample. It works perfectly with runNativeDebug. But I’m seeing issues with jvm and js targets. On jvm, it is running smoothly now but some artifacts are observed in the flag filter On js, some filters stopped working Attaching videos
p

Paulo Magalhaes

10/11/2021, 2:34 PM
I have a question: does each image have it's own context, or does the program create a single context and share between images?
s

Sahil Bajaj

10/13/2021, 8:22 AM
@Deactivated User I can still reproduce the issue on Android. Only gets fixed with glFinish
Scene:
Copy code
override suspend fun Container.sceneMain() {

    repeat(5) {
        val image = Image(resourcesVfs["korge.png"].readBitmap().slice())

        image.pos = Point(it * 200.0, it * 300.0)

        repeat(1) {
            val filter = IdentityFilter(false)
            image.addFilter(filter)
        }

        this.addChild(image)
    }
}
p

Paulo Magalhaes

10/20/2021, 6:32 PM
We did a GPU trace, and found that texImage2D was being called every frame due to dirty flag always being set to true, so we tested only setting dirty when texture changes size, and it resolved our issues with both crash and slow FPS. the commit is in this link, perhaps you could look at it and see if there's a cleaner solution of if this suffices https://github.com/invideoio/korge-next/commit/95edff817d48d3a00ce1ae15169d0689a74d7eeb
d

Deactivated User

10/22/2021, 8:04 AM
Nice! Can you make a PR?
s

Sahil Bajaj

10/22/2021, 10:32 AM
@Deactivated User Is this good to go?
d

Deactivated User

10/25/2021, 2:26 PM
@Sahil Bajaj I have been pretty busy this weekend. Ill check today!
s

Sahil Bajaj

10/25/2021, 5:04 PM
No worries... :) At your convenience.
48 Views