Closed CosmaVergari closed 1 month ago
Try / Catch statements are notoriously dangerous for their performance impact, as essentially you're copying the stack just in case something might happen.
What is the error exactly and isn't this handled in the catch
already?
I just made a change to address your point. The idea is to manage the error raised by createNativeCtxTexture
here
Ah yes, makes sense.
It would be a little cheaper to change the return value of https://github.com/lightning-js/renderer/blob/dd9461f55ae7a2946141af934c84d88335c937bb/src/core/renderers/webgl/WebGlCoreCtxTexture.ts#L248 to be a null
in case it fails and then check the value at https://github.com/lightning-js/renderer/blob/dd9461f55ae7a2946141af934c84d88335c937bb/src/core/renderers/webgl/WebGlCoreCtxTexture.ts#L88 over a try/catch block.
It won't matter that much in the sunny day scenario, Chrome 64 on x20 is a little faster for the null check but on older WebKits null check is about 60% faster. See: https://jsperf.app/siqize/2 In the negative case, generating an error chain is very very expensive: https://jsperf.app/siqize
Thank you for the suggestion, I converted the raised error to a null
return. The performance gain seems significant indeed
Thanks for your contribution!
load
method to manage the error thrown bycreateNativeCtxTexture