Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/skia/android/cpp/jni/include/JniSkiaBaseView.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ class JniSkiaBaseView {
}

virtual void unregisterView() {
getSkiaManager()->setSkiaView(
_skiaAndroidView->getSkiaView()->getNativeId(), nullptr);
getSkiaManager()->unregisterSkiaView(
_skiaAndroidView->getSkiaView()->getNativeId());
auto manager = getSkiaManager();
if (manager == nullptr || _skiaAndroidView == nullptr) {
return;
}
auto skiaView = _skiaAndroidView->getSkiaView();
if (skiaView == nullptr) {
return;
}
manager->setSkiaView(skiaView->getNativeId(), nullptr);
manager->unregisterSkiaView(skiaView->getNativeId());
}

virtual jni::local_ref<jni::JArrayInt> getBitmap(int width, int height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class RNSkiaModule extends NativeSkiaModuleSpec {

private final WeakReference<ReactApplicationContext> weakReactContext;
private SkiaManager skiaManager;
private static volatile boolean sIsValid = false;

public static boolean isModuleValid() {
return sIsValid;
}

public RNSkiaModule(ReactApplicationContext reactContext) {
super(reactContext);
Expand All @@ -26,6 +31,7 @@ public RNSkiaModule(ReactApplicationContext reactContext) {
@Override
public void invalidate() {
super.invalidate();
sIsValid = false;

if (this.skiaManager != null) {
this.skiaManager.invalidate();
Expand Down Expand Up @@ -58,6 +64,7 @@ public boolean install() {
return false;
}
skiaManager = new SkiaManager(context);
sIsValid = true;
return true;
} catch (Exception exception) {
Log.e(NAME, "Failed to initialize Skia Manager!", exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public void setOpaque(boolean value) {
}

void dropInstance() {
if (!RNSkiaModule.isModuleValid()) {
return;
}
unregisterView();
}

Expand Down
Loading