highcharts / highcharts-android

Android wrapper for Highcharts usage
Other
126 stars 30 forks source link

Hichart is lagging on some devices after second app launch #257

Closed cnik777 closed 6 months ago

cnik777 commented 1 year ago

highcharts = "10.3.2" Hichart scrubbing, touch and animation starts lagging after second app launch. Clearing the data and relaunch solves the issue for the session but starts lagging again after next cold app start.

known devices with issue oneplus nord 2 oneplus a6000

I've tested with very simple implementation

val chartView = binding.chartParent
        val options = HIOptions()
        chartView.options = options
        val chart =  HIChart()
        options.chart = chart
        val line = HILine()
        line.data = arrayListOf(1,2,3,4,3,1,2,4,5,4,3,2,1)
        val data = mutableListOf<HILine>()
        data.add(line)
        options.series = ArrayList(data)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".FirstFragment">

    <com.highsoft.highcharts.core.HIChartView
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:id="@+id/chartParent"
        android:layout_width="400dp"
        android:layout_height="400dp"/>

    <TextView
        android:id="@+id/textview_first"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_first_fragment"
        app:layout_constraintBottom_toTopOf="@id/button_first"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button_first"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/next"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/textview_first" />
</androidx.constraintlayout.widget.ConstraintLayout>

is there any internal caching or data persistance that might be causing this ? and any mechanism to clear that. Please let me know if you need any more info and specifics.

some device profiling screenshots while scrubbing through chartview left : when lagging right: smooth

Screenshot 2023-01-27 at 4 42 45 PM Screenshot 2023-01-27 at 4 50 39 PM

adding video

https://user-images.githubusercontent.com/123733976/215111095-d6e84efd-5638-4cb1-9f2c-d6859c418b4f.mp4

added sample project link used for video. https://github.com/cnik777/hicharttemp

soommy12 commented 1 year ago

Thank you @cnik777 for your notification. We are already aware of that but it's little we can do. This is directly connected with WebView performance on different smartphones which we cannot affect in any way. Anyway, I can assure you that we are constantly working on how to improve general library performance but we simply cannot verify all device models.

alessioemireni commented 1 year ago

same here. It happens also on Google Pixel 6a

alessioemireni commented 1 year ago

@soommy12 @cnik777 I have found the issue. We need to use the the hardware or software acceleration. By default is none. Below you can find an example to apply to Highcharts when you instantiates the WebView:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // chromium, enable hardware acceleration
    webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
    // older android version, disable hardware acceleration
    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

When I applied it works like a charm!