Skip to content

Add methods for rendering on worker thread #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2017

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