-
Notifications
You must be signed in to change notification settings - Fork 2k
[webgl] Reduce JS map lookups in webgl backend #7387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mattsoulanille
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nit.
| private freeTextures?: Record<string, Texture[]> = {}; | ||
| private usedTextures?: Record<string, Texture[]> = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Why is this optional (with ?) but immediately assigned? Does it get deleted somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. TextureManager.dispose() assigns nulls to them, and a lot of tests relies on this behavior (set to null after disposed) to be correct, at least they failed when I tried to make it always not null. There may be some additional guards/checks needed after we turn on the null check, but so far it's fine since it matches the old behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TextureManager.dispose() means TextureManager's singleton is disposed and thus its freeTextures and usedTextures could be disposed, which does not require freeTextures and usedTextures to be optional.
On the other hand, if freeTextures and usedTextures are optional, whenever they are used, null check is required, causing the runtime to execute more logics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rolled back and added a todo comment
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.
This change is