Last Comment Bug 784783 - [NSInternalInconsistencyException: Invalid message sent to event "NSEvent
: [NSInternalInconsistencyException: Invalid message sent to event "NSEvent
: regression
Product: Core
Classification: Components
Component: Widget: Cocoa (show other bugs)
: Trunk
: x86 Mac OS X
-- normal (vote)
: mozilla18
Assigned To: Masayuki Nakano [:masayuki]
: Markus Stange [:mstange] (away until Feb 22)
Depends on: 786956
Blocks: 775414
  Show dependency treegraph
Reported: 2012-08-22 13:24 PDT by Hubert Figuiere [:hub]
Modified: 2012-10-16 16:38 PDT (History)
7 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch (1.27 KB, patch)
2012-08-30 01:11 PDT, Masayuki Nakano [:masayuki]
smichaud: review+
Details | Diff | Splinter Review
Patch (1.28 KB, patch)
2012-08-30 21:41 PDT, Masayuki Nakano [:masayuki]
akeybl: approval‑mozilla‑aurora+
Details | Diff | Splinter Review

Description User image Hubert Figuiere [:hub] 2012-08-22 13:24:54 PDT
2012-08-22 11:55:11.641 firefox[11805:110b] *** Assertion failure in -[NSEvent characters], /SourceCache/AppKit/AppKit-1138.47/AppKit.subproj/NSEvent.m:1695
2012-08-22 11:55:11.642 firefox[11805:110b] Mozilla has caught an Obj-C exception [NSInternalInconsistencyException: Invalid message sent to event "NSEvent: type=FlagsChanged loc=(0,821) time=864407.9 flags=0x100 win=0x115003290 winNum=13629 ctxt=0x0 keyCode=0"]
2012-08-22 11:55:11.645 firefox[11805:110b] Generating stack trace for Obj-C exception...
2012-08-22 11:55:12.050 firefox[11805:110b] Stack trace:
Looking up symbols in process 11805 named:  firefox

I get this exception on nightly when switching to the application.

I get it often, but not all the time.

Here is the stack trace:

#0  0x00007fff89f5ed45 in objc_exception_throw ()
#1  0x00007fff8c525d8a in +[NSException raise:format:arguments:] ()
#2  0x00007fff8d51f71f in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] ()
#3  0x00007fff84310235 in -[NSEvent characters] ()
#4  0x0000000102eac557 in mozilla::widget::TISInputSourceWrapper::InitKeyEvent (this=0x7fff5fbfde10, aNativeKeyEvent=0x114e3be80, aKeyEvent=@0x7fff5fbfdef0, aInsertString=0x0) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#5  0x0000000102eb0623 in mozilla::widget::TextInputHandlerBase::InitKeyEvent (this=0x1152311f0, aNativeKeyEvent=0x114e3be80, aKeyEvent=@0x7fff5fbfdef0, aInsertString=0x0) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#6  0x0000000102eb1c0a in mozilla::widget::TextInputHandler::DispatchKeyEventForFlagsChanged (this=0x1152311f0, aNativeEvent=0x114e3be80, aDispatchKeyDown=false) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#7  0x0000000102eb0f2e in mozilla::widget::TextInputHandler::HandleFlagsChanged (this=0x1152311f0, aNativeEvent=0x114e3be80) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#8  0x0000000102e7b204 in -[ChildView flagsChanged:] (self=0x1150b3e00, _cmd=0x7fff84af2892, theEvent=0x114e3be80) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#9  0x00007fff8426e7ac in -[NSWindow sendEvent:] ()
#10 0x0000000102e677d5 in -[ToolbarWindow sendEvent:] (self=0x115003290, _cmd=0x7fff84b1cd42, anEvent=0x114e3be80) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#11 0x00007fff84207624 in -[NSApplication sendEvent:] ()
#12 0x0000000102e54c12 in -[GeckoNSApplication sendEvent:] (self=0x10030c230, _cmd=0x7fff84b1cd42, anEvent=0x114e3be80) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#13 0x00007fff8419e0c6 in -[NSApplication run] ()
#14 0x0000000102e56fdc in nsAppShell::Run (this=0x10a8558e0) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/
#15 0x0000000102b03287 in nsAppStartup::Run (this=0x10a09ba10) at /Users/hub/source/mozilla/mozilla-central/toolkit/components/startup/nsAppStartup.cpp:273
#16 0x000000010118b91e in XREMain::XRE_mainRun (this=0x7fff5fbfee28) at /Users/hub/source/mozilla/mozilla-central/toolkit/xre/nsAppRunner.cpp:3800
#17 0x000000010118c03f in XREMain::XRE_main (this=0x7fff5fbfee28, argc=6, argv=0x7fff5fbffa18, aAppData=0x1000081c0) at /Users/hub/source/mozilla/mozilla-central/toolkit/xre/nsAppRunner.cpp:3877
#18 0x000000010118c45f in XRE_main (argc=6, argv=0x7fff5fbffa18, aAppData=0x1000081c0, aFlags=0) at /Users/hub/source/mozilla/mozilla-central/toolkit/xre/nsAppRunner.cpp:3953
#19 0x0000000100001ebc in do_main (argc=6, argv=0x7fff5fbffa18) at /Users/hub/source/mozilla/mozilla-central/browser/app/nsBrowserApp.cpp:174
#20 0x0000000100001785 in main (argc=6, argv=0x7fff5fbffa18) at /Users/hub/source/mozilla/mozilla-central/browser/app/nsBrowserApp.cpp:279
Comment 1 User image Steven Michaud [:smichaud] (Retired) 2012-08-22 13:37:08 PDT
> Invalid message sent to event "NSEvent: type=FlagsChanged

> -[NSEvent characters]

Sounds like 'characters' is being sent to an event whose type is NSFlagsChanged.  This message is only valid for an NSKeyDown or NSKeyUp event.

It happens here:

Masayuki? :-)
Comment 2 User image Masayuki Nakano [:masayuki] 2012-08-24 17:45:09 PDT
Hmm, why the key which comes with NSFlagsChanged event is decided as isPrintableKey? I think that we should research what key causes it. I guess there is another bug such as that unnecessary keypress event is fired with modifier key.
Comment 3 User image Masayuki Nakano [:masayuki] 2012-08-30 01:11:07 PDT
Created attachment 656776 [details] [diff] [review]

This patch just prevents the exception.

The root cause is, the native event's keyCode is wrong value. The keyCode is always 0 (0 is 'A' key's keycode) in such situation. So, we're dispatching 'A' keyup event at that time. But it's not regression. Let's fix it later.
Comment 4 User image Masayuki Nakano [:masayuki] 2012-08-30 20:58:38 PDT
Comment 5 User image Phil Ringnalda (:philor) 2012-08-30 21:35:10 PDT
And just so nobody makes a mistake landing on Aurora if you're not around when it needs to land there, followed up with because that version of the patch had a stray extra ) in it.
Comment 6 User image Masayuki Nakano [:masayuki] 2012-08-30 21:41:43 PDT
Created attachment 657143 [details] [diff] [review]

I attached old patch which isn't fixed the bustage caused by redundant ")".
Comment 7 User image Philipp von Weitershausen [:philikon] 2012-08-31 10:53:12 PDT
Comment 8 User image Masayuki Nakano [:masayuki] 2012-09-06 19:56:27 PDT
Comment on attachment 657143 [details] [diff] [review]

[Approval Request Comment]
Bug caused by (feature/regressing bug #): Bug 775414
User impact if declined: Users would meet the exception and the key handling would be aborted.
Testing completed (on m-c, etc.): on m-c, we have no regression reports for this for this two weeks.
Risk to taking this patch (and alternatives if risky): almost nothing
String or UUID changes made by this patch: no
Comment 9 User image Alex Keybl [:akeybl] 2012-09-07 12:10:24 PDT
Comment on attachment 657143 [details] [diff] [review]

[Triage Comment]
Given the low risk profile of this fix, it's better to be safe than sorry and fix this exception. Approving for Aurora 17.
Comment 10 User image Masayuki Nakano [:masayuki] 2012-09-09 19:20:59 PDT
Comment 11 User image Anthony Hughes (:ashughes) [GFX][QA][Mentor] 2012-10-16 16:10:15 PDT
Hub, can you check if you still see this with the latest Firefox 17 Beta?
Comment 12 User image :Irving Reid (No longer working on Firefox) 2012-10-16 16:38:48 PDT
For what it's worth I regularly see the warning message (indicating that we avoided the originally reported exception) in Thunderbird trunk; I was seeing the exception before this fix.

Note You need to log in before you can comment on or make changes to this bug.