Skip to content

Commit

Permalink
Merge branch 'main' into fabric-build
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Nov 24, 2024
2 parents 2e637e8 + 412d3a3 commit 57bad45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/skia/cpp/rnskia/RNSkPlatformContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class RNSkPlatformContext {
std::shared_ptr<react::CallInvoker> callInvoker,
float pixelDensity)
: _pixelDensity(pixelDensity), _jsRuntime(runtime),
_callInvoker(callInvoker) {
}
_callInvoker(callInvoker) {}

virtual ~RNSkPlatformContext() = default;

Expand Down
15 changes: 11 additions & 4 deletions packages/skia/cpp/rnskia/RNSkView.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,17 @@ class RNSkView : public std::enable_shared_from_this<RNSkView> {
void requestRedraw() {
if (!_redrawRequested) {
_redrawRequested = true;
_platformContext->runOnMainThread([this]() {
if (_renderer) {
_renderer->renderImmediate(_canvasProvider);
_redrawRequested = false;
// Capture a weak pointer to this
auto weakThis = std::weak_ptr<RNSkView>(shared_from_this());

_platformContext->runOnMainThread([weakThis]() {
// Try to lock the weak pointer
if (auto strongThis = weakThis.lock()) {
// Only proceed if the object still exists
if (strongThis->_renderer) {
strongThis->_renderer->renderImmediate(strongThis->_canvasProvider);
strongThis->_redrawRequested = false;
}
}
});
}
Expand Down

0 comments on commit 57bad45

Please sign in to comment.