Skip to content

Do not compare flavor strings with == - #2050

Merged
svillar merged 1 commit into
Igalia:mainfrom
NAME-ASHWANIYADAV:fix/string-equality-flavor-checks
Aug 17, 2026
Merged

Do not compare flavor strings with ==#2050
svillar merged 1 commit into
Igalia:mainfrom
NAME-ASHWANIYADAV:fix/string-equality-flavor-checks

Conversation

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor

Fixes #2049

What

Follow-up to 9100032 ("Do not compare strings with =="), which fixed BuildConfig.FLAVOR_abi == "x64" in the Chromium RuntimeImpl. This changes the two remaining comparisons of the same shape, both in shared code:

  • SettingsStore.java:164 - AUDIO_ENABLED
  • Session.java:672 - the background-capture guard in captureBackgroundBitmap()

Style matches the earlier fix (BuildConfig.FLAVOR_backend.equals("chromium")). A grep over app/src/**/*.java confirms these were the last two.

Why

Being precise about severity: both evaluate correctly today. BuildConfig.FLAVOR_backend is generated as a public static final String with a literal initializer, so it is a compile-time constant that javac inlines, and the comparison ends up between two interned literals. So this is a robustness and readability change, not a bug fix.

It is still worth making for the same reasons as 9100032: the code reads as a value comparison while it is a reference comparison, and it silently relies on the field staying an inlined constant. If either side ever stopped being one, both checks would quietly become false - flipping the audio default (SettingsStore.java:715, ControllerOptionsView.java:99) and disabling the Chromium background-capture guard - with no compiler warning.

No behavior change in any current build variant.

Testing

  • Builds: ./gradlew assembleNoapiArm64GeckoGenericDebug
  • Existing unit tests pass: ./gradlew testNoapiArm64GeckoGenericDebugUnitTest

Follow-up to the same fix in RuntimeImpl: these two remaining
comparisons resolve correctly today only because the flavor field
inlines to an interned literal.
@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

@svillar PTAL !!

@svillar svillar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch

@svillar svillar added the release_candidate PR that should be part of the next release label Aug 17, 2026
@svillar
svillar merged commit 520a84a into Igalia:main Aug 17, 2026
3 checks passed
@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

thanks !! @svillar

@svillar svillar added this to the v1.9.1 milestone Sep 1, 2026
@svillar svillar removed the release_candidate PR that should be part of the next release label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two flavor checks still compare strings with ==

2 participants