Repository navigation
Reuse image buffer in HeadlessView - #5476
mikemorris wants to merge 5 commits into
Conversation
So the view can reuse the buffer for the next image. The assumption is that when the callback gets called it will get the data encoded to another buffer on PNG or JPEG format.
Avoid big memory allocations, also set a limit to 4096x4096@2 for now.
Now that we have implications on sharing the image buffer, we need to make sure that we don't have thread concurrency.
|
I don't think we want to bring |
| assert(dimensions[0] <= dimensionsLimits[0]); | ||
| assert(dimensions[1] <= dimensionsLimits[1]); | ||
|
|
||
| static auto image = std::make_shared<PremultipliedImage>( |
There was a problem hiding this comment.
static means that there is one buffer for the entire process.
There was a problem hiding this comment.
Ack, didn't catch that - this doesn't seem workable given how we can have multiple NodeMap objects per node process, each with their own HeadlessView?
There was a problem hiding this comment.
static means that there is one buffer for the entire process.
This is exactly the idea. I added an assert to make sure this is always called from the same thread.
There was a problem hiding this comment.
I don't think we want to limit HeadlessView to single-threaded programs. We could easily have each HeadlessView own a distinct buffer and still reuse that buffer.
There was a problem hiding this comment.
I will close this before we spend more bandwidth on it. This branch was never intended to upstream and was initially pushed to my own fork (https://github.com/tmpsantos/mapbox-gl-native/tree/tmpsantos-read_still_image). I suggest we keep experimental branchs on private forks.
No, we don't. I replaced with |
|
@mikemorris for testing this branch you have to synchronously encode the buffer into a PNG/JPEG on the |
|
@mikemorris I will leave the |
Took a shot at wiring @tmpsantos' work on reusing the image buffer in
mbgl::HeadlessViewinto the Node.js bindings, and something is definitely not right, causing segfaults during a benchmark - I'm not entirely sure how to properly handle memory management here, as I can't callimage->data.release()withstd::shared_ptr<const mbgl::PremultipliedImage>due toconst, and some other stuff changed around to usestd::unique_ptr::swapinstead ofstd::move.Can you take a closer look at this @jfirebaugh @tmpsantos, particularly the interaction between
Nan::NewBufferandmbgl::PremultipliedImage::datainNodeMap::renderFinished?