Skip to content

Conversation

@Valodim
Copy link
Contributor

@Valodim Valodim commented Sep 29, 2017

Hi there! Thanks for creating this library, much appreciated!

While giving this lib a whirl, I noticed that rendering the heatmap is quite an expensive operation to perform on the UI thread. Drawing ~100 data points took 300ms or so on my Nexus 5X, and caused a noticeable pause in the incoming transition of a fragment I used it in. I profiled this, and most of the time is spent in Canvas.native_drawCircle calls downstack of tryRefresh.

This PR adds a method forceRefreshOnWorkerThread to the heatmap class, which works similar to forceRefresh but is intended to be called on a worker thread. Internally, it calls tryRefresh and takes care of most of the expensive operations.

There are also a bunch of annotations, to support setting up a heatmap in a worker thread without getting "wrong thread" errors all over.

I tested this and the UI where I noticed this problem runs smoothly now. I also profiled before and after, the operations are properly run in the background thread now.

@tredpath tredpath merged commit 33a7196 into HeartlandSoftware:master Nov 4, 2017
@Valodim Valodim deleted the worker-thread branch November 5, 2017 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants