rive-app / rive-android

A runtime for interactive animations on Android
https://rive.app
MIT License
332 stars 30 forks source link

Out of Memory (OOM) error occurs during long running. #300

Closed SamayLi closed 10 months ago

SamayLi commented 10 months ago

I am using this Rive in Activity but when running for a long time, the following OOM occurs.How should I solve this problem? Additional information:

  1. The runtime is approximately 10-15 minutes.
  2. According to the requirements of the design team, I need to set a state value every 20ms to drive the change in animation amplitude.
    
    08-23 18:54:59.496 25263 25263 E AndroidRuntime: FATAL EXCEPTION: main
    08-23 18:54:59.496 25263 25263 E AndroidRuntime: Process: com.ss.meetx.room, PID: 25263
    08-23 18:54:59.496 25263 25263 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 55380616 byte allocation with 25165824 free bytes and 41MB until OOM, target footprint 518062048, growth limit 536870912
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at java.util.Arrays.copyOf(Arrays.java:3136)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at java.util.Arrays.copyOf(Arrays.java:3106)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at java.util.ArrayList.grow(ArrayList.java:275)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:249)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:241)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at java.util.ArrayList.add(ArrayList.java:467)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at app.rive.runtime.kotlin.core.StateMachineInstance.convertInput(StateMachineInstance.kt:95)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at app.rive.runtime.kotlin.core.StateMachineInstance.input(StateMachineInstance.kt:111)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at app.rive.runtime.kotlin.core.StateMachineInstance.input(StateMachineInstance.kt:120)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at app.rive.runtime.kotlin.controllers.RiveFileController.setNumberState(RiveFileController.kt:422)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at app.rive.runtime.kotlin.RiveAnimationView.setNumberState(RiveAnimationView.kt:471)
    08-23 18:54:59.496 25263 25263 E AndroidRuntime:    at com.ss.meetx.speech.view.SpeechLayout.changeVoiceVolume(SpeechLayout.kt:402)
umberto-sonnino commented 10 months ago

Going to close this issue since this is a duplicate of https://github.com/rive-app/rive-android/issues/297

Like I mentioned in the other thread, it might be worth upgrading to the latest version of our library (currently it's 8.2.2) as that might solve your problems. Is there anything that's preventing you from doing that?

Also, we'd really need a repro for the issue to look into it! Could you build a small sample app in a GitHub repository and share it here?

SamayLi commented 10 months ago

We are using version 4.4.0。Currently, due to issues with our project's Gradle and Kotlin versions, we are temporarily unable to use higher versions.