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/TextInputHandler.mm:728
#5 0x0000000102eb0623 in mozilla::widget::TextInputHandlerBase::InitKeyEvent (this=0x1152311f0, aNativeKeyEvent=0x114e3be80, aKeyEvent=@0x7fff5fbfdef0, aInsertString=0x0) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/TextInputHandler.mm:3816
#6 0x0000000102eb1c0a in mozilla::widget::TextInputHandler::DispatchKeyEventForFlagsChanged (this=0x1152311f0, aNativeEvent=0x114e3be80, aDispatchKeyDown=false) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/TextInputHandler.mm:1546
#7 0x0000000102eb0f2e in mozilla::widget::TextInputHandler::HandleFlagsChanged (this=0x1152311f0, aNativeEvent=0x114e3be80) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/TextInputHandler.mm:1497
#8 0x0000000102e7b204 in -[ChildView flagsChanged:] (self=0x1150b3e00, _cmd=0x7fff84af2892, theEvent=0x114e3be80) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/nsChildView.mm:4151
#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/nsCocoaWindow.mm:2711
#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/nsAppShell.mm:157
#13 0x00007fff8419e0c6 in -[NSApplication run] ()
#14 0x0000000102e56fdc in nsAppShell::Run (this=0x10a8558e0) at /Users/hub/source/mozilla/mozilla-central/widget/cocoa/nsAppShell.mm:756
#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
> 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:
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.
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.
And just so nobody makes a mistake landing on Aurora if you're not around when it needs to land there, followed up with https://hg.mozilla.org/integration/mozilla-inbound/rev/a962ec74a526 because that version of the patch had a stray extra ) in it.
Created attachment 657143 [details] [diff] [review]
I attached old patch which isn't fixed the bustage caused by redundant ")".
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 on attachment 657143 [details] [diff] [review]
Given the low risk profile of this fix, it's better to be safe than sorry and fix this exception. Approving for Aurora 17.
Hub, can you check if you still see this with the latest Firefox 17 Beta?
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.