[Android] Fix: WebView clamping small CSS font sizes - #36559
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36559Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36559" |
|
Hey there @@SubhikshaSf4851! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR addresses Android WebView’s default minimum font-size behavior that can clamp small CSS font sizes (e.g., < 8px), impacting rendering in MAUI WebView and MAUI Blazor WebView scenarios. It lowers the Android WebSettings minimum font sizes to allow small CSS font-size values to render as specified and adds an Issue page + UI test coverage.
Changes:
- Set
MinimumFontSizeandMinimumLogicalFontSizeto1when updating Android WebView settings (core WebView path). - Set
MinimumFontSizeandMinimumLogicalFontSizeto1when creating the Android BlazorWebView platform view (Blazor path). - Add a HostApp issue page and corresponding UI test asserting small computed font size behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Core/src/Platform/Android/WebViewExtensions.cs | Sets Android WebView minimum font size settings during UpdateSettings to prevent clamping. |
| src/BlazorWebView/src/Maui/Android/BlazorWebViewHandler.Android.cs | Sets Android BlazorWebView minimum font size settings during platform view creation. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue26924.cs | Adds a HostApp repro page that computes and displays the span’s computed font size. |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26924.cs | Adds a UI test that validates the computed font size behavior. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| var html = $@" | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head></head> | ||
| <body> | ||
| <p>Hi, this is a paragraph.</p> | ||
| <span id=""{SmallFontSpanId}"" style=""font-size:{SmallFontCssValue};"">tiny span text</span> | ||
| </body> | ||
| </html>"; |
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Globalization; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Components.WebView.Maui; |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@SubhikshaSf4851 — new AI review results are available based on this last commit:
8af6bee. To request a fresh review after new comments or commits, comment/review rerun.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ⚠️ INCONCLUSIVE
Platform: ANDROID
⚠️ verify-tests-fail.ps1exited before writing a verification report. Diagnostics below.
Exit code: 3
Likely cause:
- Device/emulator setup failed (env error class).
Artifacts written before exit:
verification-log.txt(2.1 KB)
Gate output log (last 60 lines)
ℹ️ USER_WARNING | AVD 'Emulator_30' will run more smoothly with 4 CPU cores (currently using 2).
ℹ️ FATAL | Running multiple emulators with the same AVD is an experimental feature.Please use -read-only flag to enable this feature.
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Still waiting... (90 seconds elapsed)
ℹ️ Emulator log (last 5 lines):
ℹ️ INFO | Ok: Hardware GPU compatibility checks are not required
ℹ️ INFO | Checking: hasSufficientSystem
ℹ️ INFO | Warning: AVD 'Emulator_30' will run more smoothly with 4 CPU cores (currently using 2)
ℹ️ USER_WARNING | AVD 'Emulator_30' will run more smoothly with 4 CPU cores (currently using 2).
ℹ️ FATAL | Running multiple emulators with the same AVD is an experimental feature.Please use -read-only flag to enable this feature.
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Device found but offline, waiting...
ℹ️ Still waiting... (120 seconds elapsed)
ℹ️ Emulator log (last 5 lines):
ℹ️ INFO | Ok: Hardware GPU compatibility checks are not required
ℹ️ INFO | Checking: hasSufficientSystem
ℹ️ INFO | Warning: AVD 'Emulator_30' will run more smoothly with 4 CPU cores (currently using 2)
ℹ️ USER_WARNING | AVD 'Emulator_30' will run more smoothly with 4 CPU cores (currently using 2).
ℹ️ FATAL | Running multiple emulators with the same AVD is an experimental feature.Please use -read-only flag to enable this feature.
❌ Emulator failed to start within 120 seconds. Please try starting it manually.
ℹ️ Current adb devices:
ℹ️ Emulator log (last 30 lines):
ℹ️ INFO | Android emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
ℹ️ INFO | Graphics backend: gfxstream
ℹ️ INFO | Found systemPath /usr/local/lib/android/sdk/system-images/android-30/google_apis_playstore/x86_64/
ℹ️ WARNING | Please update the emulator to one that supports the feature(s): Vulkan
ℹ️ INFO | Increasing RAM size to 2048MB
ℹ️ ##############################################################################
ℹ️ ## WARNING - ACTION REQUIRED ##
ℹ️ ## Consider using the '-metrics-collection' flag to help improve the ##
ℹ️ ## emulator by sending anonymized usage data. Or use the '-no-metrics' ##
ℹ️ ## flag to bypass this warning and turn off the metrics collection. ##
ℹ️ ## In a future release this warning will turn into a one-time blocking ##
ℹ️ ## prompt to ask for explicit user input regarding metrics collection. ##
ℹ️ ## ##
ℹ️ ## Please see '-help-metrics-collection' for more details. You can use ##
ℹ️ ## '-metrics-to-file' or '-metrics-to-console' flags to see what type of ##
ℹ️ ## data is being collected by emulator as part of usage statistics. ##
ℹ️ ##############################################################################
ℹ️ INFO | Guest GLES Driver: Auto (ext controls)
ℹ️ INFO | emuglConfig_init: vulkan_mode_selected:swiftshader gles_mode_selected:swiftshader
ℹ️ INFO | Checking system compatibility:
ℹ️ INFO | Checking: hasSufficientDiskSpace
ℹ️ INFO | Ok: Disk space requirements to run avd: `Emulator_30` are met
ℹ️ INFO | Checking: hasSufficientHwGpu
ℹ️ INFO | Ok: Hardware GPU compatibility checks are not required
ℹ️ INFO | Checking: hasSufficientSystem
ℹ️ INFO | Warning: AVD 'Emulator_30' will run more smoothly with 4 CPU cores (currently using 2)
ℹ️ USER_WARNING | AVD 'Emulator_30' will run more smoothly with 4 CPU cores (currently using 2).
ℹ️ FATAL | Running multiple emulators with the same AVD is an experimental feature.Please use -read-only flag to enable this feature.
❌ Failed to boot device
📱 UI Tests — ViewBaseTests,WebView
Detected UI test categories: ViewBaseTests,WebView
✅ Deep UI tests — 169 passed, 0 failed across 2 categories on platform-pool agent (replaces in-process counts above).
🧪 UI Test Execution Results (deep, platform pool)
| Category | Tests | Snapshot diffs |
|---|---|---|
ViewBaseTests |
118/119 ✓ | — |
WebView |
51/51 ✓ | — |
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs) |
📋 Pre-Flight — Context & Validation
Issue: #26924 - Font Size of span Element Not Rendering Correctly in Mobile Mode in .NET MAUI Blazor
PR: #36559 - Fix Android WebView small CSS font-size clamping
Platforms Affected: Android
Files Changed: 2 implementation, 3 test
Key Findings
- Issue #26924 reports Android-rendered MAUI/Blazor WebView content clamping a
4.87761pxCSS span to a much larger size; comments confirm repro on Android and note it is not Blazor-specific. - PR fix sets Android WebView
MinimumFontSizeandMinimumLogicalFontSizeto1in both ControlsWebViewExtensions.UpdateSettingsandBlazorWebViewHandler.CreatePlatformView. - Regression coverage was added for Android BlazorWebView device tests and Controls WebView UI tests.
- Gate result supplied to this run is inconclusive because the prior gate could not build/run in the environment; this pre-flight did not rerun gate verification.
Code Review Summary
Verdict: NEEDS_DISCUSSION
Confidence: low
Errors: 0 | Warnings: 2 | Suggestions: 2
Key code review findings:
- ⚠
src/Core/src/Platform/Android/WebViewExtensions.cs:44changes every Android ControlsWebView, not just BlazorWebView; this global behavior shift may be intentional but deserves confirmation. - ⚠
src/Core/src/Platform/Android/WebViewExtensions.cs:44removes Android WebView's 8px minimum font-size floor globally, creating an accessibility/readability tradeoff. - ℹ
src/BlazorWebView/src/Maui/Android/BlazorWebViewHandler.Android.cs:52duplicates the magic value/rationale fromWebViewExtensions.cs. - ℹ
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26924.cs:30has an extra blank line at EOF pergit diff --check.
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #36559 | Set Android WebView MinimumFontSize and MinimumLogicalFontSize to 1 in both Controls WebView and BlazorWebView setup, with device/UI regression tests. |
⚠ INCONCLUSIVE (Gate) | BlazorWebViewHandler.Android.cs, WebViewExtensions.cs, 3 test files |
Original PR; code appears functionally targeted but global Android WebView behavior/accessibility tradeoff needs maintainer confirmation. |
🔬 Code Review — Deep Analysis
Code Review — PR #36559
Independent Assessment
What this changes: Lowers Android WebView/BlazorWebView MinimumFontSize and MinimumLogicalFontSize to 1 so CSS sizes below Android's default 8px floor are not clamped. Adds Blazor device coverage and Controls UI coverage.
Inferred motivation: Fix Android-rendered MAUI Blazor content where tiny CSS text renders larger than authored.
Reconciliation with PR Narrative
Author claims: Fixes #26924 by preventing Android WebView font-size clamping and adds tests.
Agreement/disagreement: Matches the implementation. Note the fix also affects all Android WebView controls, not only BlazorWebView.
Prior Review Reconciliation
No prior ❌ Error findings found. Earlier non-error Copilot comments about brittle exact assertions and missing Blazor coverage appear addressed; the viewport-meta suggestion remains a non-blocking test-stability concern.
Blast Radius Assessment
- Runs for all instances: Yes —
WebViewExtensions.UpdateSettingsbacks all Android ControlsWebViewinstances. - Startup impact: No app startup impact; applies during handler/platform view setup.
- Static/shared state: No.
CI Status
- Required-check result:
gh pr checks --requiredunavailable due missing GitHub CLI auth. - Public check evidence:
maui-prpassed,maui-pr-devicetestspassed, Android WebView UITest passed; overallmaui-pr-uitestsand Build Analysis are failing/pending-combined with failures in unrelated UI categories. - Classification: undetermined/likely unrelated, but not fully classifiable without authenticated required-check/AzDO detail.
- Action taken: invoked
azdo-build-investigator;ci-analysisskill unavailable. Confidence capped low.
Findings
⚠️ Warning — Global Android WebView behavior change
src/Core/src/Platform/Android/WebViewExtensions.cs:44 changes every Android Controls WebView, not just BlazorWebView. Existing apps relying on Android's 8px minimum floor may render smaller embedded/third-party content after upgrade. This may be intentional, but should be confirmed/documented as a default behavior change.
⚠️ Warning — Accessibility tradeoff
src/Core/src/Platform/Android/WebViewExtensions.cs:44 removes Android WebView's minimum font-size floor globally. Please confirm Android accessibility/text scaling still provides an acceptable readability fallback for users who relied on the platform floor.
💡 Suggestion — Avoid duplicated magic value
src/BlazorWebView/src/Maui/Android/BlazorWebViewHandler.Android.cs:52 duplicates 1 and the rationale from WebViewExtensions.cs. A shared constant/helper would reduce drift.
💡 Suggestion — Extra blank line at EOF
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26924.cs:30 triggers git diff --check with "new blank line at EOF."
Failure-Mode Probing
- WebView without tiny CSS: now permits sub-8px text everywhere; no crash path found.
- Handler disconnect/reconnect: settings are per platform view; no subscriptions/static state added.
- Null Settings: existing null guard in
UpdateSettings; Blazor path checksSettings != null. - Test race: current UI test waits for "px" before parsing, addressing prior race.
Verdict: NEEDS_DISCUSSION
Confidence: low
Summary: The code appears functionally sound and covered for the targeted Android paths, but the global default/accessibility behavior change deserves maintainer confirmation. CI cannot be fully verified from gh required checks in this environment, so this cannot be LGTM.
🛠️ Fix — Analysis & Comparison
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| 1 | maui-expert-reviewer | Source-scoped tiny CSS support using HtmlWebViewSource detection in Core WebViewHandler. |
❌ FAIL | 3 product files | Compile failed because Core cannot reference Controls-only HtmlWebViewSource; rejected as architecturally invalid. |
| 2 | maui-expert-reviewer | Apply minimum font-size only for MauiWebView.LoadHtml, restore Android defaults for URL loads, keep Blazor explicit. |
⚠ BLOCKED | 3 product files | Targeted Android builds passed; runtime device test hung at instrumentation. Reduces blast radius but excludes URL content. |
| 3 | maui-expert-reviewer | Apply minimum font-size for MAUI-owned inline HTML and local asset URLs, restore defaults for external URLs, keep Blazor explicit. | ⚠ BLOCKED | 3 product files | Targeted Android builds passed; runtime not rerun after same-environment instrumentation hang. Best blast-radius alternative, but not fully verified. |
| PR | PR #36559 | Set Android WebView MinimumFontSize and MinimumLogicalFontSize to 1 globally for Controls WebView settings and explicitly for BlazorWebView. |
⚠ INCONCLUSIVE (Gate) | 2 product files + 3 tests | Original PR; simplest and broadest fix, but global Controls WebView behavior/accessibility tradeoff remains. |
Cross-Pollination
| Model | Round | New Ideas? | Details |
|---|---|---|---|
| maui-expert-reviewer | 1 | Yes | Proposed source-scoped HtmlWebViewSource detection. Failed because Core cannot reference Controls type. |
| maui-expert-reviewer | 2 | Yes | Proposed LoadHtml-scoped Core delegate fix. Build-passing but runtime-blocked and narrower than PR. |
| maui-expert-reviewer | 3 | Yes | Proposed MAUI-owned-content scoped fix covering inline HTML and local assets. Build-passing but runtime-blocked and still narrower than PR. |
Exhausted: Yes
Selected Fix: PR #36559 — No alternative candidate passed all tests and was demonstrably better. Candidate #3 is the strongest alternative if maintainers want reduced blast radius for remote URL WebViews, but it remains runtime-unverified and changes the intended product semantics by not fixing ordinary remote URL content.
Learned From Failures
- Core-layer fixes cannot reference Controls-layer source types such as
HtmlWebViewSource; source-specific behavior must be expressed through Core abstractions (IWebViewDelegate.LoadHtml, URL classification) or moved up-layer. - Scoped fixes can reduce the global behavior/accessibility concern, but they trade off completeness: remote
UrlWebViewSourcecontent remains clamped unless the PR's broader global setting is used. - The local Android environment could build and install the BlazorWebView device-test APK, but the runtime test path hung at
adb shell am instrument -w ..., so no candidate received full runtime validation.
🏁 Report — Final Recommendation
Comparative Report — PR #36559
Candidates evaluated
| Candidate | Approach | Regression/build status | Rank | Rationale |
|---|---|---|---|---|
pr |
Set Android WebView MinimumFontSize and MinimumLogicalFontSize to 1 in both Controls WebView settings and BlazorWebView creation. |
1 | Directly fixes the Android WebView font-size clamp for BlazorWebView and standard Controls WebView. Expert review found no actionable code changes required. | |
pr-plus-reviewer |
Same as pr; expert reviewer produced no actionable findings, so no sandbox patch was applied. |
2 | Equivalent to pr. Ranked just below the raw PR only because it introduces no distinct improvement. |
|
try-fix-3 |
Scope the minimum-font override to MAUI-owned inline/local WebView content and keep BlazorWebView explicit. | 3 | Best alternative from a blast-radius perspective, but narrower than the PR: ordinary external/remote WebView content would still be clamped. It is also runtime-unverified. | |
try-fix-2 |
Scope the Controls WebView override to LoadHtml and restore defaults for URL loads; keep BlazorWebView explicit. |
4 | Reduces global behavior change but covers less than try-fix-3 and excludes URL-based WebView content. Runtime verification did not complete. |
|
try-fix-1 |
Attempt source-scoped behavior by detecting HtmlWebViewSource in Core WebView handler. |
❌ Failed compile | 5 | Must rank below candidates that did not fail. Core cannot reference Controls-only HtmlWebViewSource, so the approach is architecturally invalid. |
Winning candidate
Winner: pr
The raw PR fix is the best candidate because it is the simplest complete fix for the reported Android WebView clamp and the expert reviewer found no actionable changes to apply. The scoped try-fix candidates reduce blast radius, but they either fail to compile (try-fix-1) or intentionally leave some WebView content sources under Android's default clamp while remaining runtime-unverified (try-fix-2, try-fix-3).
The global behavior/accessibility concern remains a maintainer judgment call, not a demonstrated regression-test failure or correctness defect. Given the rule that failed candidates rank below non-failing candidates, try-fix-1 is last; the blocked scoped candidates do not displace the submitted PR because they are not demonstrably better and are less complete.
🧭 Next Steps — review latest findings
No alternative fix was selected for this run. Review the session findings and CI results before merging.
<!-- Please keep the note below for people who find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment whether this change resolves your issue. Thank you!<!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue where small CSS font sizes (below 8px) were being clamped up by the Android WebView's default minimum font size, causing them to render larger than specified in .NET MAUI Blazor apps. The changes ensure that small font size rendered correctly by explicitly setting lower minimum font size values in the Android WebView settings. Additionally, new test cases have been added to verify the fix. ### Android WebView font size handling * Explicitly set `MinimumFontSize` and `MinimumLogicalFontSize` to `1` in Android WebView initialization and settings update methods to prevent the platform from clamping small CSS font sizes. [[1]](diffhunk://#diff-745160d3986f59a60c86d338d2bf5659491cb445df33de8fdef26cec9e8b58a5R52-R53) [[2]](diffhunk://#diff-ca62b285e626480e971cc257bb277985d30081c0e2754e25cb58517aca3430f6R42-R45) ### Testing * Added a new UI test page (`Issue26924`) to demonstrate and verify that a `<span>` with a small font size (4.87761px) renders correctly in a Blazor WebView. * Added an automated test to assert that the computed font size for the test span remains at 4.87761px, confirming the fix works as intended. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #26924 ### Tested the behavior in the following platforms - [ ] Windows - [x] Android - [ ] iOS - [ ] Mac ### Snapshots : | Before Fix | After Fix | |--------------------------|---------------------------| | <img width="1080" height="2400" alt="BeforeFix26924" src="https://github.com/user-attachments/assets/e7712ded-271b-4b75-8807-5433c1721e22" /> | <img width="1080" height="2400" alt="Afterfix26924" src="https://github.com/user-attachments/assets/a820cda0-4674-4793-833a-aa163b559be4" />| <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
<!-- Please keep the note below for people who find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment whether this change resolves your issue. Thank you!<!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue where small CSS font sizes (below 8px) were being clamped up by the Android WebView's default minimum font size, causing them to render larger than specified in .NET MAUI Blazor apps. The changes ensure that small font size rendered correctly by explicitly setting lower minimum font size values in the Android WebView settings. Additionally, new test cases have been added to verify the fix. ### Android WebView font size handling * Explicitly set `MinimumFontSize` and `MinimumLogicalFontSize` to `1` in Android WebView initialization and settings update methods to prevent the platform from clamping small CSS font sizes. [[1]](diffhunk://#diff-745160d3986f59a60c86d338d2bf5659491cb445df33de8fdef26cec9e8b58a5R52-R53) [[2]](diffhunk://#diff-ca62b285e626480e971cc257bb277985d30081c0e2754e25cb58517aca3430f6R42-R45) ### Testing * Added a new UI test page (`Issue26924`) to demonstrate and verify that a `<span>` with a small font size (4.87761px) renders correctly in a Blazor WebView. * Added an automated test to assert that the computed font size for the test span remains at 4.87761px, confirming the fix works as intended. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #26924 ### Tested the behavior in the following platforms - [ ] Windows - [x] Android - [ ] iOS - [ ] Mac ### Snapshots : | Before Fix | After Fix | |--------------------------|---------------------------| | <img width="1080" height="2400" alt="BeforeFix26924" src="https://github.com/user-attachments/assets/e7712ded-271b-4b75-8807-5433c1721e22" /> | <img width="1080" height="2400" alt="Afterfix26924" src="https://github.com/user-attachments/assets/a820cda0-4674-4793-833a-aa163b559be4" />| <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
<!-- Please keep the note below for people who find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment whether this change resolves your issue. Thank you!<!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue where small CSS font sizes (below 8px) were being clamped up by the Android WebView's default minimum font size, causing them to render larger than specified in .NET MAUI Blazor apps. The changes ensure that small font size rendered correctly by explicitly setting lower minimum font size values in the Android WebView settings. Additionally, new test cases have been added to verify the fix. ### Android WebView font size handling * Explicitly set `MinimumFontSize` and `MinimumLogicalFontSize` to `1` in Android WebView initialization and settings update methods to prevent the platform from clamping small CSS font sizes. [[1]](diffhunk://#diff-745160d3986f59a60c86d338d2bf5659491cb445df33de8fdef26cec9e8b58a5R52-R53) [[2]](diffhunk://#diff-ca62b285e626480e971cc257bb277985d30081c0e2754e25cb58517aca3430f6R42-R45) ### Testing * Added a new UI test page (`Issue26924`) to demonstrate and verify that a `<span>` with a small font size (4.87761px) renders correctly in a Blazor WebView. * Added an automated test to assert that the computed font size for the test span remains at 4.87761px, confirming the fix works as intended. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #26924 ### Tested the behavior in the following platforms - [ ] Windows - [x] Android - [ ] iOS - [ ] Mac ### Snapshots : | Before Fix | After Fix | |--------------------------|---------------------------| | <img width="1080" height="2400" alt="BeforeFix26924" src="https://github.com/user-attachments/assets/e7712ded-271b-4b75-8807-5433c1721e22" /> | <img width="1080" height="2400" alt="Afterfix26924" src="https://github.com/user-attachments/assets/a820cda0-4674-4793-833a-aa163b559be4" />| <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
<!-- Please keep the note below for people who find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment whether this change resolves your issue. Thank you!<!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue where small CSS font sizes (below 8px) were being clamped up by the Android WebView's default minimum font size, causing them to render larger than specified in .NET MAUI Blazor apps. The changes ensure that small font size rendered correctly by explicitly setting lower minimum font size values in the Android WebView settings. Additionally, new test cases have been added to verify the fix. ### Android WebView font size handling * Explicitly set `MinimumFontSize` and `MinimumLogicalFontSize` to `1` in Android WebView initialization and settings update methods to prevent the platform from clamping small CSS font sizes. [[1]](diffhunk://#diff-745160d3986f59a60c86d338d2bf5659491cb445df33de8fdef26cec9e8b58a5R52-R53) [[2]](diffhunk://#diff-ca62b285e626480e971cc257bb277985d30081c0e2754e25cb58517aca3430f6R42-R45) ### Testing * Added a new UI test page (`Issue26924`) to demonstrate and verify that a `<span>` with a small font size (4.87761px) renders correctly in a Blazor WebView. * Added an automated test to assert that the computed font size for the test span remains at 4.87761px, confirming the fix works as intended. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #26924 ### Tested the behavior in the following platforms - [ ] Windows - [x] Android - [ ] iOS - [ ] Mac ### Snapshots : | Before Fix | After Fix | |--------------------------|---------------------------| | <img width="1080" height="2400" alt="BeforeFix26924" src="https://github.com/user-attachments/assets/e7712ded-271b-4b75-8807-5433c1721e22" /> | <img width="1080" height="2400" alt="Afterfix26924" src="https://github.com/user-attachments/assets/a820cda0-4674-4793-833a-aa163b559be4" />| <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
<!-- Please keep the note below for people who find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment whether this change resolves your issue. Thank you!<!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> This pull request addresses an issue where small CSS font sizes (below 8px) were being clamped up by the Android WebView's default minimum font size, causing them to render larger than specified in .NET MAUI Blazor apps. The changes ensure that small font size rendered correctly by explicitly setting lower minimum font size values in the Android WebView settings. Additionally, new test cases have been added to verify the fix. ### Android WebView font size handling * Explicitly set `MinimumFontSize` and `MinimumLogicalFontSize` to `1` in Android WebView initialization and settings update methods to prevent the platform from clamping small CSS font sizes. [[1]](diffhunk://#diff-745160d3986f59a60c86d338d2bf5659491cb445df33de8fdef26cec9e8b58a5R52-R53) [[2]](diffhunk://#diff-ca62b285e626480e971cc257bb277985d30081c0e2754e25cb58517aca3430f6R42-R45) ### Testing * Added a new UI test page (`Issue26924`) to demonstrate and verify that a `<span>` with a small font size (4.87761px) renders correctly in a Blazor WebView. * Added an automated test to assert that the computed font size for the test span remains at 4.87761px, confirming the fix works as intended. <!-- Enter description of the fix in this section --> ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #26924 ### Tested the behavior in the following platforms - [ ] Windows - [x] Android - [ ] iOS - [ ] Mac ### Snapshots : | Before Fix | After Fix | |--------------------------|---------------------------| | <img width="1080" height="2400" alt="BeforeFix26924" src="https://github.com/user-attachments/assets/e7712ded-271b-4b75-8807-5433c1721e22" /> | <img width="1080" height="2400" alt="Afterfix26924" src="https://github.com/user-attachments/assets/a820cda0-4674-4793-833a-aa163b559be4" />| <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment whether this change resolves your issue. Thank you!
This pull request addresses an issue where small CSS font sizes (below 8px) were being clamped up by the Android WebView's default minimum font size, causing them to render larger than specified in .NET MAUI Blazor apps. The changes ensure that small font size rendered correctly by explicitly setting lower minimum font size values in the Android WebView settings. Additionally, new test cases have been added to verify the fix.
Android WebView font size handling
MinimumFontSizeandMinimumLogicalFontSizeto1in Android WebView initialization and settings update methods to prevent the platform from clamping small CSS font sizes. [1] [2]Testing
Issue26924) to demonstrate and verify that a<span>with a small font size (4.87761px) renders correctly in a Blazor WebView.Issues Fixed
Fixes #26924
Tested the behavior in the following platforms
Snapshots :