Log error caught when creating WebGL context #3969
Merged
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.
My day today: I spent a long time debugging the error
Initialization of backend webgl failedon a particular machine. Ultimately, the cause was really obscure: Chrome was returningnullfromcanvas.getContextwhen passed thisfailIfMajorPerformanceCaveatflag. Another line in TensorFlow assumes thatgetContextcannot return null, and so throws an errorTypeError: Cannot read property 'isContextLost' of null. This is another bug. But that error was then silently swallowed at the line here.On restarting the machine, Chrome mysteriously stopped behaving this way. But that underlying issue is a story for another time.
The point is, silently swallowing all thrown errors is a pretty bad practice. To go further, unless we actually expect errors thrown here, I think this
try/catchshould be removed - if it fails unexpectedly, just let it fail. If we do expect errors thrown here, that should at least be documented in a comment here.This change is