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
10 changes: 9 additions & 1 deletion src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1466,8 +1466,16 @@ export class CoreNode extends EventEmitter {
}

if (this.texture !== null) {
needsTextureOwnership = true;
// preemptive check for failed textures this will mark the current node as non-renderable
// and will prevent further checks until the texture is reloaded or retry is reset on the texture
if (this.texture.retryCount > this.texture.maxRetryCount) {
// texture has failed to load, we cannot render
this.updateTextureOwnership(false);
this.setRenderable(false);
return;
}

needsTextureOwnership = true;
// we're only renderable if the texture state is loaded
newIsRenderable = this.texture.state === 'loaded';
} else if (
Expand Down
2 changes: 1 addition & 1 deletion src/core/textures/ImageTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class ImageTexture extends Texture {
const resolvedProps = ImageTexture.resolveDefaults(props);
super(txManager);
this.props = resolvedProps;
this.maxRetryCount = props.maxRetryCount as number;
this.maxRetryCount = resolvedProps.maxRetryCount ?? 5;
}

hasAlphaChannel(mimeType: string) {
Expand Down
8 changes: 2 additions & 6 deletions src/core/textures/Texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export abstract class Texture extends EventEmitter {
public memUsed = 0;

public retryCount = 0;
public maxRetryCount: number | null = null;
public maxRetryCount: number = 5;

/**
* Timestamp when texture was created (for startup grace period)
Expand Down Expand Up @@ -292,11 +292,7 @@ export abstract class Texture extends EventEmitter {
}

load(): void {
if (this.maxRetryCount === null && this.retryCount > 0) {
return;
}

if (this.maxRetryCount !== null && this.retryCount > this.maxRetryCount) {
if (this.retryCount > this.maxRetryCount) {
// We've exceeded the max retry count, do not attempt to load again
return;
}
Expand Down