Skip to content
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

artemp/issue 978 #979

Merged
merged 15 commits into from
Oct 27, 2021
Merged

artemp/issue 978 #979

merged 15 commits into from
Oct 27, 2021

Conversation

artemp
Copy link
Member

@artemp artemp commented Oct 21, 2021

Improve Image and ImageView objects scopes and lifetime management.

  • This PR adds Ref() / Unref() logic to Image::encode and ImageView::encode async methods.
    Under load input Image /ImageView objects can get GC-ed while AsyncEncode::Execute methods hasn't completed. To avoid this, we increment reference count in sync part or the encode and decrement in async handler when op is complete ( AsyncEncode::OnWorkComplete(Napi::Env env, napi_status status) )

  • Add persistent Buffer reference to Image to ensure underlying buffer stays in scope (in situations when Image doesn't own underlyling data)

  • Image - update ctor and remove ad-hoc _buffer field

  • Use Napi::EscapableHandleScope in Image::buffer and Image::data

src/mapnik_image.cpp Outdated Show resolved Hide resolved
Copy link
Member

@springmeyer springmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks like a great improvement since it fixes a critical issue that (I think?) regressed. I've added some comments inline below. Could you also add a general description to the PR that:

  • describes what was broken (and why)
  • describes why this now works right

@artemp artemp merged commit c50e463 into master Oct 27, 2021
@artemp artemp deleted the artemp/issue-978 branch October 27, 2021 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants