-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add CPU-only rendering mode for CanvasKit as a fallback #19823
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
htmlElement = htmlCanvas; | ||
return CkSurface(skSurface, _grContext!, glContext); | ||
CkSurface _makeSoftwareCanvasSurface(html.CanvasElement htmlCanvas) { | ||
print('WARNING: failed to initialize WebGL. Falling back to CPU-only rendering.'); |
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.
Use console.warn
. Also only send this error once. As written this will print this warning every time we resize the browser or add a platform view.
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.
Done.
_grContext = | ||
canvasKit.callMethod('MakeGrContext', <dynamic>[glContext]); | ||
|
||
if (_grContext == null) { |
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.
If we were able to create a GL context but failed to create a graphics context then something is seriously wrong. I think we should throw here
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.
Done.
@hterkelsen PTAL |
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
Description
Some browsers do not support WebGL. In that case fallback to CPU-only rendering mode, which is slower but consistent with the GPU version of CanvasKit.
Related Issues
flutter/devtools#2125