Repository navigation
Conversation
…eout, LRU eviction - Image textures use the stage's maxRetryCount instead of a hard 5 the src setter never overrode, and wait between retries (1s doubling to 60s) instead of spending them all back to back. - A texture whose node enters the viewport uploads ahead of textures preloading in the bounds margin. - WebPlatform.fetch fails after 15s, so a request that never completes (seen on tvOS NativeScript) is retried instead of hanging forever. - Memory cleanup frees the least recently shown textures first instead of the oldest loaded. Ported from the Hoichoi Apple TV patch on @solidtv/renderer 1.10.2.
A healthy poster request finishes well under a second; at 15s a stalled request held the image back far longer than the retry needs to recover it.
Author
|
Hi @chiefcll could you please review once ? thank you! |
|
👋 - I'll take a look and see if this is needed on the other renderer, this isn't the SolidTV renderer, it's the one used on LightningJS |
|
FYI - closing out. The nativescript 2.0 should be using renderer 2.0 and everything in here is in that... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On a NativeScript tvOS app (Apple TV,
@nativescript/canvasWebGL, no image workers), poster cards sometimes stayed empty for the rest of the session. They were worst after navigating back to a page and while a video played under the canvas. Four renderer behaviours combined to cause it:CoreNode'ssrcsetter creates theImageTexturewithoutmaxRetryCount, soresolveDefaultsfilled in a hard5. The stage'smaxRetryCountnever reached an image. The retries also ran back to back, so a few seconds of bad network used them all up, and the node was never drawn again.WebPlatform.fetchhas no deadline, so that image never loaded and never failed, which means it never retried either.What changes
ImageTexturekeeps the stage'smaxRetryCountunless one is passed explicitly (maxRetryCount?: number | null, defaultnull). After a failure the nextload()waits, doubling from 1s to 60s (Texture.retryAt, with a timer that reloads only if a node still owns the texture).textures/ImageTexture.ts,textures/Texture.tsInViewport, its texture moves to the front of the upload queue (CoreTextureManager.prioritize). A texture whose node came on screen while it was still fetching is queued at the front. A frame counter (CoreTextureManager.frame, advanced inStage.drawFrame) dates this.CoreNode.ts,CoreTextureManager.ts,Stage.tsWebPlatform.fetchrejects after 5s and aborts the XHR, so the texture fails and goes through the retry path. A healthy poster request finishes well under a second.platforms/web/WebPlatform.tsTextureMemoryManager.cleanupfrees textures least recently on screen first (Texture.lastOnScreen). Textures still owned by a node count as on screen now.TextureMemoryManager.ts,textures/Texture.tsCoreNodetest stage mock gets atxManager, whichupdateRenderStatenow calls.CoreNode.test.tsBehaviour for apps that set nothing: images now retry
maxRetryCounttimes (default 5, as before), with a growing wait instead of immediately. Nothing else changes until a texture fails, a node enters the viewport or memory cleanup runs.Testing
tsc --buildpasses.vitest run: 8 files, 115 tests pass. ESLint shows no errors; theno-explicit-anywarnings were there before this change.pnpm patchon@solidtv/renderer1.10.2. On the tvOS simulator, a test server returned 503 for one poster for 40s and then served it. The renderer made one request at a time at 4, 6, 8, 12, 20 and 36s, and the poster appeared at 68s, in 2 runs out of 2. Back to a page after scrolling another showed every poster with no refetch, and the log showed no console errors.Notes
@solidtv/renderer1.10.2, whose source isn't in this repo, and this branch is the@lightningjs/renderer3.0.5 tree. The 1.10.2 patch also gives uploads a 4ms budget while animations run, instead of one texture per frame. This tree already uses the time budget, so that part has no counterpart here.apps/appletv/patches/@solidtv__renderer@1.10.2.patch, with notes inapps/appletv/patches/README.md.