Skip to content

Commit

Permalink
Merge branch 'fabric-build' of https://github.com/Shopify/react-nativ…
Browse files Browse the repository at this point in the history
…e-skia into fabric-build
  • Loading branch information
wcandillon committed Nov 24, 2024
2 parents c4bb53d + 57bad45 commit 73e068b
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 73e068b

Please sign in to comment.