Skip to content

Commit

Permalink
fix(🤖): fix vulkan/angle support (#2801)
Browse files Browse the repository at this point in the history
These seem to mostly affect samsung devices.
  • Loading branch information
wcandillon authored Dec 11, 2024
1 parent 2cfa890 commit e9bb166
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,7 @@ public void setOpaque(boolean value) {
}
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (getMeasuredWidth() == 0) {
if (mView instanceof SkiaTextureView) {
((SkiaTextureView) mView).createSurfaceTexture();
}
}
}

void dropInstance() {
if (mView instanceof SkiaTextureView) {
((SkiaTextureView)mView).isDropped = true;
}
unregisterView();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public class SkiaTextureView extends TextureView implements TextureView.SurfaceT

SkiaViewAPI mApi;
boolean mDebug;
boolean pristine = true;

public boolean isDropped = false;

public SkiaTextureView(Context context, SkiaViewAPI api, boolean debug) {
super(context);
Expand All @@ -27,22 +24,6 @@ public SkiaTextureView(Context context, SkiaViewAPI api, boolean debug) {
setSurfaceTextureListener(this);
}

public void createSurfaceTexture() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
Log.i(tag, "Create SurfaceTexture");
SurfaceTexture surfaceTexture = new SurfaceTexture(false);
setSurfaceTexture(surfaceTexture);
onSurfaceTextureAvailable(surfaceTexture, getWidth(), getHeight());
}
}

private void reCreateSurfaceTexture() {
boolean surfaceIsAlreadyAvailable = getSurfaceTexture() != null;
if (surfaceIsAlreadyAvailable) {
createSurfaceTexture();
}
}

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
Expand All @@ -57,23 +38,13 @@ public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surfaceTexture, in
@Override
public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surfaceTexture, int width, int height) {
Log.i(tag, "onSurfaceTextureSizeChanged: " + width + "x" + height);
if (isDropped) {
return;
}
mApi.onSurfaceTextureCreated(surfaceTexture, width, height);
mApi.onSurfaceTextureChanged(surfaceTexture, width, height);
}

@Override
public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) {
mApi.onSurfaceDestroyed();
// Because of React Native Screens (which dettach the view), we always keep the surface alive.
// If not, Texture view will recreate the texture surface by itself and
// we will lose the fast first time to frame.
// We only delete the surface when the view is dropped (destroySurface invoked by SkiaBaseViewManager);
if (!isDropped) {
reCreateSurfaceTexture();
}
return false;
return true;
}

private long _prevTimestamp = 0;
Expand Down

0 comments on commit e9bb166

Please sign in to comment.