Repository navigation
BidiUtils.wrapText restores spans to incorrect ranges or drops them in 1.11.1 #3455
Description
Version
Media3 1.11.1
More version details
Actual released media3-ui BidiUtils.wrapText invoked by reflection on Android; its implementation was not copied. Current main source was also inspected and retains the same offset mechanism; main was not runtime-tested.
Devices that reproduce the issue
Android SDK36 x86_64 emulator. Base system locale en-US; Locale.setDefault changes only diagnostic app process (en-US/ar-SA/fa-IR/he-IL), not system locale. This is a helper reproduction, not a full RTL UI playback certification.
Devices that do not reproduce the issue
No device claim. Several selected en-US input cases preserve their spans, included in measured results.
Reproducible in the demo app?
Not tested. Buildable isolated diagnostic Activity and complete targeted runtime results are attached. Public reproducer was built and runtime-checked.
Reproduction steps
- Depend on media3-ui:1.11.1 and create a SpannableString
Hello مرحبا, with one StyleSpan(BOLD) on Hello at[0,5). - Invoke actual BidiUtils.wrapText reflectively under process locale en-US. The output still contains Hello at[0,5), but that same span object is restored at[1,6).
مرحبا Hello\nWorld, with span on World, drops the span after invalid computed offsets. RTL formatter contexts and CRLF expose further wrong offsets.- Attached SpanVisualActivity supplies this minimal case plus unchanged real Arabic/Persian/Hebrew SubDL cue text. It injects a bold/red diagnostic span on a unique word and compares restored range with that word's actual location in the wrapped string. Run
--es locale en-US --ei case 0; also ar-SA case2, fa-IR case5, he-IL case7. Collect SPAN_REAL records.
Fresh suite: 40 actual helper probes, ten each under four process locales. Eight real-text probes and two synthetic controls per locale. Wrong ranges:2/10 en-US and10/10 under each RTL locale. These are selected mechanism probes, not population failure rates. Previous independent nine-case suite (27 probes) adds CRLF/line-crossing evidence and en-US dropped-span reproduction.
Expected result
Each original span stays on the same visible word following insertion of direction controls and EOL normalization.
Actual result
The restored span shifts or drops. The implementation assumes one inserted unit before/after a wrapped line whenever its length grows. unicodeWrap can insert controls on one side only, or two on each side in an RTL formatter context. CRLF normalization also changes cumulative offsets.
#2553 already reviewed lost styling and added restoration. This report concerns incorrect restored ranges in the shipped helper, rather than the initial PR's complete styling removal. It is separate from paragraph/punctuation direction and requires no subtitle conversion.
Media
Not applicable to encoded video. Attached minimal Activity, selected result JSON and actual screenshot comparison. Expected panel explicitly restores span to the same unique word in the actual wrapped output; it is a reference, not another player/version. Diagnostic styling was added; source caption words were unchanged. No full archives or device-wide logs included.
Reproducer and verified visual evidence
Public minimal reproducer and measured results. The README explains how to decode the ZIP and verify SHA-256.
Activity
tonihei commentedon Oct 9, 2026
Thanks for reporting, we'll take a look.
Fix RTL subtitle punctuation and span preservation in BidiUtils