New issue
Advanced search Search tips

Issue 773565 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 1
Type: Bug

Blocking:
issue 603386



Sign in to add a comment

MacViews: Check failed: ui::TextEditCommand::INVALID_COMMAND == scheduled_text_edit_command_ (57 vs. 50) with "త"

Project Member Reported by tapted@chromium.org, Oct 11 2017

Issue description

Chrome Version       : 63.0.3218.0
OS Version: OS X 10.12.6

What steps will reproduce the problem?
1. Show the bookmarks bubble to get a text field
2. Copy-paste the character "త"
3. Try navigating with the cursor


What is the expected result?

No DCHECK


What happens instead of that?

DCHECK:

[39685:775:1011/113007.464993:FATAL:textfield.cc(1621)] Check failed: ui::TextEditCommand::INVALID_COMMAND == scheduled_text_edit_command_ (57 vs. 50)
0   libbase.dylib                       0x000000010a48f50e base::debug::StackTrace::StackTrace(unsigned long) + 174
1   libbase.dylib                       0x000000010a48f5cd base::debug::StackTrace::StackTrace(unsigned long) + 29
2   libbase.dylib                       0x000000010a48d87c base::debug::StackTrace::StackTrace() + 28
3   libbase.dylib                       0x000000010a52687f logging::LogMessage::~LogMessage() + 479
4   libbase.dylib                       0x000000010a5241e5 logging::LogMessage::~LogMessage() + 21
5   libviews.dylib                      0x0000000138d6e034 views::Textfield::SetTextEditCommandForNextKeyEvent(ui::TextEditCommand) + 228
6   libviews.dylib                      0x0000000138c6a75b -[BridgedContentView handleAction:keyCode:domCode:eventFlags:] + 459
7   libviews.dylib                      0x0000000138c6dd6c -[BridgedContentView moveLeft:] + 60
8   libviews.dylib                      0x0000000138c700bb -[BridgedContentView doCommandBySelector:] + 171
9   AppKit                              0x00007fffa7c081d1 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] + 118
10  AppKit                              0x00007fffa7be5e00 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 2218
11  AppKit                              0x00007fffa84277b1 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke.1096 + 355
12  AppKit                              0x00007fffa84275e5 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke_3 + 80
13  AppKit                              0x00007fffa7bedf59 -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 93
14  AppKit                              0x00007fffa8427560 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke.1086 + 262
15  HIToolbox                           0x00007fffa94ea89f __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 + 70
16  HIToolbox                           0x00007fffa94e96e2 ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke + 108
17  AppKit                              0x00007fffa84204f8 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke.314 + 2874
18  AppKit                              0x00007fffa7be7835 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 80
19  AppKit                              0x00007fffa7be77b4 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 93
20  AppKit                              0x00007fffa7be719f -[NSTextInputContext handleTSMEvent:completionHandler:] + 2221
21  AppKit                              0x00007fffa7be6883 _NSTSMEventHandler + 321
22  HIToolbox                           0x00007fffa948fd85 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1708
23  HIToolbox                           0x00007fffa948eff6 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 428
24  HIToolbox                           0x00007fffa948ee3f SendEventToEventTargetWithOptions + 43
25  HIToolbox                           0x00007fffa94e66d6 SendTSMEvent_WithCompletionHandler + 408
26  HIToolbox                           0x00007fffa94e6bb1 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 400
27  HIToolbox                           0x00007fffa94e6a12 __SendFilterTextEvent_WithCompletionHandler_block_invoke + 215
28  HIToolbox                           0x00007fffa94e6727 SendTSMEvent_WithCompletionHandler + 489
29  HIToolbox                           0x00007fffa94e6511 SendFilterTextEvent_WithCompletionHandler + 236
30  HIToolbox                           0x00007fffa94e61d6 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 284
31  HIToolbox                           0x00007fffa94e5f8c __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 296
32  HIToolbox                           0x00007fffa94e5e32 __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 439
33  HIToolbox                           0x00007fffa94e5bf9 TSMKeyEvent_WithCompletionHandler + 632
34  HIToolbox                           0x00007fffa94e5948 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 251
35  HIToolbox                           0x00007fffa94e5775 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 281
36  HIToolbox                           0x00007fffa94e548b __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 308
37  HIToolbox                           0x00007fffa94e51c2 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 300
38  HIToolbox                           0x00007fffa94e473a TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3604
39  AppKit                              0x00007fffa84273d1 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke.1077 + 116
40  AppKit                              0x00007fffa8426689 __204-[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:]_block_invoke.1003 + 121
41  AppKit                              0x00007fffa84264f3 -[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:] + 285
42  AppKit                              0x00007fffa8426e1b -[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:] + 1515
43  AppKit                              0x00007fffa8426362 -[NSTextInputContext _handleEvent:allowingSyntheticEvent:] + 114
44  AppKit                              0x00007fffa7be528b -[NSView interpretKeyEvents:] + 232
45  libviews.dylib                      0x0000000138c6c6fd -[BridgedContentView keyDown:] + 189
46  AppKit                              0x00007fffa83472cc -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 4086
47  AppKit                              0x00007fffa8345f0a -[NSWindow(NSEventRouting) sendEvent:] + 541
48  libviews.dylib                      0x0000000138c9701d -[NativeWidgetMacNSWindow sendEvent:] + 381
49  AppKit                              0x00007fffa81cb4a8 -[NSApplication(NSEvent) sendEvent:] + 4768
50  libchrome_dll.dylib                 0x00000001131d9c03 __34-[BrowserCrApplication sendEvent:]_block_invoke + 259
51  libbase.dylib                       0x000000010a52b8ba base::mac::CallWithEHFrame(void () block_pointer) + 10
52  libchrome_dll.dylib                 0x00000001131d998f -[BrowserCrApplication sendEvent:] + 575
53  AppKit                              0x00007fffa7a45427 -[NSApplication run] + 1002
 

Comment 1 by tapted@chromium.org, Oct 11 2017

Also worth noting that "nothing bad" seems to happen in Release -- it's just the DCHECK getting hit in debug builds.

Comment 2 by tapted@chromium.org, Oct 13 2017

hah - 50 is PASTE. This happens with ascii text too. We just need to clear out scheduled_text_edit_command_ on PASTE.
The problem is more complex:

Case 1:
  1. Copy any text to clipboard
  2. Run Chromium browser. I checked a local build on commit 0728a85617eae06098373349af80c28ce26b60fd
  3. Set focus to omnibox and paste the text via the app menu. Do not press any key.
  4. Press any key and PASTE command is executed again!

Case 2:
  1. Chromium browser. I checked a local build on commit 0728a85617eae06098373349af80c28ce26b60fd
  2. Set focus to omnibox and type any text.
  3. Select all and perform the COPY command twice. Use the app's menu and do not press any key. DCHECK occurs:
     [57552:775:1025/115743.926114:FATAL:textfield.cc(1621)] Check failed: ui::TextEditCommand::INVALID_COMMAND == scheduled_text_edit_command_ (57 vs. 49)

Comment 4 by tapted@chromium.org, Oct 26 2017

re: #c3 - do they happen outside the omnibox? Those might be specific to OmniboxViewViews which overrides a few things and might not be coordinating with Textfield properly.
re: #c4 - both cases from #c3 can be easily reproduced with bookmarks bubble.
The problem is mac specific and the root of it is in src/ui/views/controls/textfield/textfield.cc:

Case 1: 
in function |handleAction| (src/ui/views/cocoa/bridged_content_view.mm) an editing command is stored for future by calling the |Textfield::SetTextEditCommandForNextKeyEvent| function but then immediately executed. When an user press any key, the stored editing command is executed again in function |Textfield::OnKeyPressed| because |scheduled_text_edit_command_| is not cleared after first execution of the command.

Case 2: the reason is the same as in Case 1 - DCHECK in |Textfield::SetTextEditCommandForNextKeyEvent| because |scheduled_text_edit_command_| is not cleared after first execution of the command.

Locally I fixed this by adding |scheduled_text_edit_command_ = ui::TextEditCommand::INVALID_COMMAND;| in the function |Textfield::ExecuteTextEditCommand| just after the switch statement. But I'm not sure about the fix.
Components: Internals>Views

Comment 7 by tapted@chromium.org, Nov 24 2017

Status: Started (was: Assigned)
http://crrev.com/c/788632
Project Member

Comment 8 by bugdroid1@chromium.org, Nov 28 2017

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

commit a8d23c3e4f19bf3bd7b652c5cb2a38bf608e51cc
Author: Trent Apted <tapted@chromium.org>
Date: Tue Nov 28 01:10:53 2017

MacViews: Don't handle cut/copy/paste accelerators in views::Textfield

This probably "regressed" in r503368, which fixed a use case for
accelerator handling. But that meant that accelerator handling happened
before Textfield::OnKeyEvent() handling, resulting in a stray edit
command because Textfield::AcceleratorPressed() doesn't clear it.
However, Textfield::AcceleratorPressed() doesn't do the right thing on
Mac anyway.

On Mac, these always dispatch via the responder chain and the `Edit`
menu in the main menu bar. This ensures they obey custom key mappings
that a user may have set up in System Preferences via string matching
on the specific menu items.

Bug:  773565 
Change-Id: Ic09db94866b6bd37791517505b24211c6c1105c4
Reviewed-on: https://chromium-review.googlesource.com/788632
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519500}
[modify] https://crrev.com/a8d23c3e4f19bf3bd7b652c5cb2a38bf608e51cc/ui/views/controls/textfield/textfield.cc
[modify] https://crrev.com/a8d23c3e4f19bf3bd7b652c5cb2a38bf608e51cc/ui/views/controls/textfield/textfield_unittest.cc

Status: Fixed (was: Started)

Sign in to add a comment