New issue
Advanced search Search tips

Issue 609004 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

RenderTextHarfBuzz: failing DCHECK in AddLineSegment

Project Member Reported by tapted@chromium.org, May 4 2016

Issue description

Chrome Version       : 51.0.2704.19
OS Version: OS X 10.11.4

Not sure whether this is Mac-specific.


What steps will reproduce the problem?
1. Open views_examples
2. Select the "Multiline RenderText" example
3. Type random things into the "Sample Text" field. Sometimes it crashes, with

Check failed: std::abs(last_segment.x_range.end() - segment.x_range.start()) <= std::numeric_limits<float>::epsilon() (3.05176e-05 vs. 1.19209e-07)

https://code.google.com/p/chromium/codesearch#chromium/src/ui/gfx/render_text_harfbuzz.cc&q=render_text_harfbuzz.cc:409&sq=package:chromium&l=409

has 


      // Merge segments that belong to the same run.
      if (last_segment.run == segment.run) {
        DCHECK_EQ(last_segment.char_range.end(), segment.char_range.start());
        DCHECK_LE(
            std::abs(last_segment.x_range.end() - segment.x_range.start()),
            std::numeric_limits<float>::epsilon());

Stack:

libgfx.dylib`gfx::(anonymous namespace)::HarfBuzzLineBreaker::AddLineSegment(this=0x00007fff5fbfa970, segment=0x0000000120e48ce0) + 877 at render_text_harfbuzz.cc:407
libgfx.dylib`gfx::(anonymous namespace)::HarfBuzzLineBreaker::AddWordToLine(this=0x00007fff5fbfa970, word_segments=size=1) + 1007 at render_text_harfbuzz.cc:362
libgfx.dylib`gfx::(anonymous namespace)::HarfBuzzLineBreaker::ConstructMultiLines(this=0x00007fff5fbfa970) + 1917 at render_text_harfbuzz.cc:302
libgfx.dylib`gfx::RenderTextHarfBuzz::EnsureLayout(this=0x0000000120e27050) + 2685 at render_text_harfbuzz.cc:1117
libgfx.dylib`gfx::RenderText::UpdateDisplayText(this=0x000000012a1201d0, text_width=0) + 2690 at render_text.cc:1076
libgfx.dylib`gfx::RenderTextHarfBuzz::EnsureLayoutRunList(this=0x000000012a1201d0) + 1377 at render_text_harfbuzz.cc:1562
libgfx.dylib`gfx::RenderTextHarfBuzz::GetDisplayText(this=0x000000012a1201d0) + 480 at render_text_harfbuzz.cc:796
 libgfx.dylib`gfx::RenderTextHarfBuzz::GetGraphemeIterator(this=0x000000012a1201d0) + 152 at render_text_harfbuzz.cc:1572
 libgfx.dylib`gfx::RenderTextHarfBuzz::IsValidCursorIndex(this=0x000000012a1201d0, index=1) + 328 at render_text_harfbuzz.cc:1061
 libgfx.dylib`gfx::RenderText::ApplyStyle(this=0x000000012a1201d0, style=DIAGONAL_STRIKE, value=true, range=0x00007fff5fbfc050) + 88 at render_text.cc:757
 libviews_examples_lib.dylib`views::examples::MultilineExample::RenderTextView::SetText(this=0x000000012a1242c0, new_contents=0x0000000120f87f08) + 728 at multiline_example.cc:101
 libviews_examples_lib.dylib`views::examples::MultilineExample::ContentsChanged(this=0x0000000120f1e900, sender=0x00000001228d1a00, new_contents=0x0000000120f87f08) + 55 at multiline_example.cc:176
 libviews_examples_lib.dylib`non-virtual thunk to views::examples::MultilineExample::ContentsChanged(this=0x0000000120f1e900, sender=0x00000001228d1a00, new_contents=0x0000000120f87f08) + 58 at multiline_example.cc:174
 libviews.dylib`views::Textfield::UpdateAfterChange(this=0x00000001228d1a00, text_changed=true, cursor_changed=true) + 128 at textfield.cc:1704
 libviews.dylib`views::Textfield::DoInsertChar(this=0x00000001228d1a00, ch=108) + 214 at textfield.cc:1665
 libviews.dylib`views::Textfield::InsertChar(this=0x00000001228d1a00, event=0x00007fff5fbfc438) + 251 at textfield.cc:1492
 libviews.dylib`non-virtual thunk to views::Textfield::InsertChar(this=0x00000001228d1a00, event=0x00007fff5fbfc438) + 52 at textfield.cc:1480
 libviews.dylib`-[BridgedContentView insertText:replacementRange:](self=0x000000012a305c30, _cmd="insertText:replacementRange:", text=@"l", replacementRange=location=9223372036854775807, length=0) + 835 at bridged_content_view.mm:876
 AppKit`-[NSTextInputContext(NSInputContext_WithCompletion) insertText:replacementRange:completionHandler:] + 79
 AppKit`__55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2250 + 127
 AppKit`-[NSTextInputContext do_HandleTSMEvent_insertFixLenTextLoop:whileCondition:dispatchWorkEach:afterEachInsertText:continuation:] + 181
 AppKit`-[NSTextInputContext tryHandleTSMEvent_insertFixLenText_withContext:dispatchCondition:setupForDispatch:nestedWorkaroundCondition:nestedWorkaroundDispatchWork:loopCondition:dispatchWorkEach:afterEachInsertText:continuation:] + 428
 AppKit`__55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke176 + 4253
 AppKit`__55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 95
 AppKit`-[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 101
 AppKit`-[NSTextInputContext handleTSMEvent:completionHandler:] + 3173
 AppKit`_NSTSMEventHandler + 324
 HIToolbox`DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1231
 HIToolbox`SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 404
 HIToolbox`SendEventToEventTargetWithOptions + 43
 HIToolbox`SendTSMEvent_WithCompletionHandler + 417
 HIToolbox`__SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 400
 HIToolbox`__SendFilterTextEvent_WithCompletionHandler_block_invoke + 189
 HIToolbox`SendTSMEvent_WithCompletionHandler + 497
 HIToolbox`SendFilterTextEvent_WithCompletionHandler + 236
 HIToolbox`SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 284
 HIToolbox`__utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 296
 HIToolbox`__utDeliverTSMEvent_WithCompletionHandler_block_invoke + 437
 HIToolbox`TSMKeyEvent_WithCompletionHandler + 721
 HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 251
 HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 325
 HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 261
 HIToolbox`__TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 253
 HIToolbox`TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3199
 AppKit`__61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke955 + 131
 AppKit`-[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:] + 131
 AppKit`-[NSTextInputContext _handleEvent:options:completionHandler:] + 1266
 AppKit`-[NSTextInputContext handleEvent:] + 109
 AppKit`-[NSView interpretKeyEvents:] + 204
 libviews.dylib`-[BridgedContentView keyDown:](self=0x000000012a305c30, _cmd="keyDown:", theEvent=0x0000000120e4bc70) + 131 at bridged_content_view.mm:551
 AppKit`-[NSWindow _reallySendEvent:isDelayedEvent:] + 2108
 AppKit`-[NSWindow sendEvent:] + 517
 libviews.dylib`-[NativeWidgetMacNSWindow sendEvent:](self=0x0000000120a125c0, _cmd="sendEvent:", event=0x0000000120e4bc70) + 199 at native_widget_mac_nswindow.mm:110
 AppKit`-[NSApplication sendEvent:] + 4382
 AppKit`-[NSApplication run] + 796

What is the expected result?

No DCHECK

What happens instead of that?

Screencast attached
 
multiline-elision-crash.mov
4.8 MB Download
Cc: msw@chromium.org
Owner: x...@chromium.org
Status: Assigned (was: Unconfirmed)
Assigning to xdai@ who wrote the DCHECK.

Comment 2 by x...@chromium.org, May 4 2016

I didn't notice any similar reports from other systems. I think it might be not accurate to use std::numeric_limits<float>::epsilon() as the absolute error margin since last_segment.x_range.end() and segment.x_range.start() might be very large and epsilon() could end up being smaller than the smallest rounding error of std::abs(last_segment.x_range.end() - segment.x_range.start()). 

Alternatively, I think we can use the relative error margin to compare these two floats or just remove the DCHECK.
Project Member

Comment 3 by bugdroid1@chromium.org, May 5 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e5a5bbfd2365c4c9f1f6cf97a56f0cd15b1c3132

commit e5a5bbfd2365c4c9f1f6cf97a56f0cd15b1c3132
Author: xdai <xdai@chromium.org>
Date: Thu May 05 01:37:20 2016

Fix the DCHECK failure in render_text_harfbuzz.cc.

It's reported that DCHECK failed in AddLineSegment(). The reason might be
that it's not accurate to use std::numeric_limits<float>::epsilon() as the absolute
error margin to compare two floats since last_segment.x_range.end() and
segment.x_range.start() might be very large and epsilon() could end up being
smaller than the rounding error of std::abs(last_segment.x_range.end() - segment.x_range.start()).
Or there's likely floating math rounding errors somewhere that caused this DCHECK error.

We change the DCHECK to check the difference between one run and the next
is less than 1.0 (i.e., less than one pixel).

BUG= 609004 

Review-Url: https://codereview.chromium.org/1945283003
Cr-Commit-Position: refs/heads/master@{#391724}

[modify] https://crrev.com/e5a5bbfd2365c4c9f1f6cf97a56f0cd15b1c3132/ui/gfx/render_text_harfbuzz.cc

Comment 4 by x...@chromium.org, May 5 2016

Status: Fixed (was: Assigned)

Sign in to add a comment