Skip to content

Remove the vello_cpu compilation option and enable it by default#41820

Merged
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:remove-vello-cpu-configuration-option
Jan 12, 2026
Merged

Remove the vello_cpu compilation option and enable it by default#41820
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:remove-vello-cpu-configuration-option

Conversation

@mrobinson
Copy link
Copy Markdown
Member

@mrobinson mrobinson commented Jan 10, 2026

There is currently no way to disable canvas on the whole in Servo, so
one canvas backend must be enabled for the build to succeed. Currently,
the Vello GPU backend is much slower than the CPU backend, as it
downloads pixels to CPU memory before reuploading them and displaying
them. Fixing that requires allowing rendering Vello GPU contents to a
OpenGL texture or some kind of surface that can be represented by an
OpenGL texture during display.

Historically, the approach that other browsers have taken with regard to
GPU canvas is that CPU canvas is used as a fallback until the GPU
version can be counted on to be reliably faster. I think that Servo
should take the same approach. We should always expose a CPU version of
canvas and a GPU version. Embedders should not care about how these are
implemented, just that they work as expected and perform well.

Testing: This change just adjusts the build configuration option, so no tests are necessary.
Fixes: #40779

@mrobinson mrobinson requested a review from sagudev as a code owner January 10, 2026 08:56
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 10, 2026
@sagudev
Copy link
Copy Markdown
Member

sagudev commented Jan 10, 2026

I am pretty sure that at one point it was allowed to disable both vello_cpu and vello and servo would still compiled, getCanvas("2d") would than returned null. Maybe we should investigate to still make this possible again (if it's not anymore), as disabling of specific components is one of most requested features for embedded servo AFAIK.

@mrobinson
Copy link
Copy Markdown
Member Author

I am pretty sure that at one point it was allowed to disable both vello_cpu and vello and servo would still compiled, getCanvas("2d") would than returned null. Maybe we should investigate to still make this possible again (if it's not anymore), as disabling of specific components is one of most requested features for embedded servo AFAIK.

I suspect this was possible when we still had the raqote backend, but since it has been removed it isn't possible. I agree that disabling canvas on the whole could be an interesting possibility. That's a much larger task though and if canvas is enabled at all, we would want to enable the Vello CPU backend unconditionally in that case.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jan 10, 2026
@sagudev
Copy link
Copy Markdown
Member

sagudev commented Jan 10, 2026

I am pretty sure that at one point it was allowed to disable both vello_cpu and vello and servo would still compiled, getCanvas("2d") would than returned null. Maybe we should investigate to still make this possible again (if it's not anymore), as disabling of specific components is one of most requested features for embedded servo AFAIK.

I suspect this was possible when we still had the raqote backend, but since it has been removed it isn't possible. I agree that disabling canvas on the whole could be an interesting possibility. That's a much larger task though and if canvas is enabled at all, we would want to enable the Vello CPU backend unconditionally in that case.

I tried to find where we lost the ability but I couldn't determine exactly. The biggest problem why we lost it is because we never tested in CI. In the future we should probably do build with no (or minimal if some are required) feature enabled (maybe as part of MSRV/libservo check).

Copy link
Copy Markdown
Contributor

@nicoburns nicoburns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonble. FYI, the binary size cost for vello_cpu is ~200kb.

@mrobinson mrobinson added this pull request to the merge queue Jan 11, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 11, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 11, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 11, 2026
@sagudev
Copy link
Copy Markdown
Member

sagudev commented Jan 11, 2026

So we do have runtime support for no canvas backend:

OK /_mozilla/mozilla/canvas/invalid.html

FAIL [expected PASS] subtest: Invalid canvas backend returns null context

assert_equals: expected null but got object "[object CanvasRenderingContext2D]"

@mrobinson mrobinson force-pushed the remove-vello-cpu-configuration-option branch from f706557 to 7ce91f9 Compare January 12, 2026 07:52
@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jan 12, 2026
@mrobinson
Copy link
Copy Markdown
Member Author

I've just gone ahead and removed this test since it is not valid any longer.

@mrobinson mrobinson enabled auto-merge January 12, 2026 07:53
@mrobinson mrobinson force-pushed the remove-vello-cpu-configuration-option branch from 7ce91f9 to 478c0a6 Compare January 12, 2026 10:11
@mrobinson mrobinson added this pull request to the merge queue Jan 12, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 12, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 12, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 12, 2026
There is currently no way to disable canvas on the whole in Servo, so
one canvas backend must be enabled for the build to succeed. Currently,
the Vello CPU backend is much slower than the CPU backend, as it
downloads pixels to CPU memory before reuploading them and displaying
them. Fixing that requires allowing rendering Vello GPU contents to a
OpenGL texture or some kind of surface that can be represented by an
OpenGL texture during display.

Historically, the approach that other browsers have taken with regard to
GPU canvas is that CPU canvas is used as a fallback until the GPU
version can be counted on to be reliably faster. I think that Servo
should take the same approach. We should always expose a CPU version of
canvas and a GPU version. Embedders should not care about how these are
implemented, just that they work as expected and perform well.

Fixes: servo#40779
Signed-off-by: Martin Robinson <[email protected]>
@mrobinson mrobinson force-pushed the remove-vello-cpu-configuration-option branch from 478c0a6 to 13075a4 Compare January 12, 2026 22:37
@servo-highfive servo-highfive removed the S-tests-failed The changes caused existing tests to fail. label Jan 12, 2026
@mrobinson mrobinson enabled auto-merge January 12, 2026 22:37
@mrobinson mrobinson added this pull request to the merge queue Jan 12, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 12, 2026
Merged via the queue into servo:main with commit bf45233 Jan 12, 2026
29 checks passed
@mrobinson mrobinson deleted the remove-vello-cpu-configuration-option branch January 12, 2026 23:25
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error message if libservo is compiled without vello and vello_cpu

4 participants