bugfix: Fix mapping of enums to feature IDs#1538
Merged
Merged
Conversation
The instructions in the mojom file[1](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/mojom/use_counter/metrics/webdx_feature.mojom;l=35-47;drc=822a70f9ac61a75babe9d24ddfc32ab475acc7e1) were updated to reflect how feature developers should translate feature IDs found in the web features repo to enum labels in the mojom file by doing the equivalent of `id.title().replace("-", "")` However, our code takes the enum labels and tries to map convert labels to feature IDs. Unfortunately, there's too much data loss to reliably convert back to the feature ID. Examples: * **Case 1: `http3` (WebDX ID) -> `Http3` (Enum Label)** The original ID `http3` has **no hyphen** between the letter 'p' and the digit '3'. A reverse algorithm designed to insert hyphens (e.g., between letters and digits) would incorrectly produce `http-3`. * **Case 2: `canvas-2d-color-management` (WebDX ID) -> `Canvas2DColorManagement` (Enum Label)** Here, the original ID *does* have hyphens (e.g., `canvas-2d`). However, the enum label `Canvas2DColorManagement` provides no explicit signal for these specific hyphens. An algorithm that didn't insert hyphens (to avoid breaking `http3`) would then fail to restore them. As a result, we now get all the feature IDs, convert them in their respective labels and try to use them. There are some labels that have special cases. We handle those as well with a short special cases mapping.
2747f0e to
a7c60ee
Compare
jrobbins
approved these changes
Jun 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The instructions in the mojom file[1] were updated to reflect how feature developers should translate feature IDs found in the web features repo to enum labels in the mojom file by doing the equivalent of
id.title().replace("-", "")However, our code takes the enum labels and tries to map convert labels to feature IDs.
Unfortunately, there's too much data loss to reliably convert back to the feature ID.
Examples:
Case 1:
http3(WebDX ID) ->Http3(Enum Label) The original IDhttp3has no hyphen between the letter 'p' and the digit '3'. A reverse algorithm designed to insert hyphens (e.g., between letters and digits) would incorrectly producehttp-3.Case 2:
canvas-2d-color-management(WebDX ID) ->Canvas2DColorManagement(Enum Label) Here, the original ID does have hyphens (e.g.,canvas-2d). However, the enum labelCanvas2DColorManagementprovides no explicit signal for these specific hyphens. An algorithm that didn't insert hyphens (to avoid breakinghttp3) would then fail to restore them.As a result, we now get all the feature IDs, convert them using the equivalent algorithm in Go into their respective labels and try to use them. There are some labels that have special cases. We handle those as well with a short special cases mapping.
We still have a logging message that the log based metrics check for. That is now emitted two potential places so that string is now a constant variable.