| Summary: | [Cocoa]StyledText: IME-related "Argument not valid" error handling keyDown | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Thomas Singer <eclipse> | ||||||||
| Component: | SWT | Assignee: | Alexandr Miloslavskiy <alexandr.miloslavskiy> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | major | ||||||||||
| Priority: | P3 | CC: | alexandr.miloslavskiy, karsten.thoms, loskutov, niraj.modi, ts-swt | ||||||||
| Version: | 4.3 | Keywords: | triaged | ||||||||
| Target Milestone: | 4.18 M3 | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | All | ||||||||||
| See Also: |
https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/170823 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=2a9595e067812151c4c2b3df2bbcba7c10ddf3ae |
||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Thomas Singer
Hi Thomas, Seeing the stacktrace, exception is thrown from method DefaultContent.getLineAtOffset() - As per Java doc of DefaultContent.getLineAtOffset(int lineIndex), this method throws IllegalArgumentException when lineIndex is out of range, which is the case here. Any set of steps/Snippet that can be used to reproduce this issue would be needed ? Also note, the stacktrace you shared is generated from cocoa code(MAC). (In reply to Niraj Modi from comment #1) > Any set of steps/Snippet that can be used to reproduce this issue would be > needed ? Unfortunately, no. > Also note, the stacktrace you shared is generated from cocoa code(MAC). Yes, I forgot to change the OS X default (reported on Windows). A similar exception was also reported on Windows 7 32-bit: java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:4378) at org.eclipse.swt.SWT.error(SWT.java:4312) at org.eclipse.swt.SWT.error(SWT.java:4283) at org.eclipse.swt.custom.DefaultContent.replaceTextRange(DefaultContent.java:768) at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5805) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5662) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:505) at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:367) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4637) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4977) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757) at com.syntevo.q.gui.QSwt.dispatchEvents(SourceFile:251) at com.syntevo.smartgit.SaApplicationStarter.openGui(SourceFile:294) at com.syntevo.smartgit.SaApplicationStarter.parse(SourceFile:187) at com.syntevo.sc.application.ScParsingApplicationStarter.start(SourceFile:62) at SmartGit.main(SourceFile:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at QBootLoader.main(SourceFile:114) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.exe4j.runtime.LauncherEngine.launch(Unknown Source) at com.exe4j.runtime.WinLauncher.main(Unknown Source) Another similar error has been reported for SmartGit 6 on Windows 8: java.lang.IllegalArgumentException at org.eclipse.swt.SWT.error(SWT.java:4378) at org.eclipse.swt.SWT.error(SWT.java:4312) at org.eclipse.swt.SWT.error(SWT.java:4283) at org.eclipse.swt.custom.DefaultContent.error(DefaultContent.java:670) at org.eclipse.swt.custom.DefaultContent.getLineAtOffset(DefaultContent.java:564) at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3633) at org.eclipse.swt.custom.StyledText.showCaret(StyledText.java:10140) at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5818) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:5662) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) at org.eclipse.swt.widgets.IME.WM_IME_COMPOSITION(IME.java:505) at org.eclipse.swt.widgets.Canvas.WM_IME_COMPOSITION(Canvas.java:367) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4637) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4977) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757) We have 285 bug reports regarding this exception. (In reply to Thomas Singer from comment #5) > We have 285 bug reports regarding this exception. ... and still no idea how it can be reproduced? Unfortunately, not steps how to reproduce - just the stacktraces. Maybe you could add some early assertions? Created attachment 280593 [details]
Repro snippet
According to quick debugging, this is the bug of macOS itself: it sends 'setMarkedText:selectedRange:' [1] with: markedText = "modifi" selectedRange.location = 8 Where 'selectedRange.location' is obviously outside the text. The bug is also visible in macOS terminal: upon typing the final 'd' caret suddenly jumps 2 lines down. When another character is typed, caret returns. [1] https://developer.apple.com/documentation/uikit/uitextinput/1614465-setmarkedtext?language=objc (In reply to Alexandr Miloslavskiy from comment #8) > Created attachment 280593 [details] > Repro snippet Could not reproduce with the instructions. Here is a short screencast. What am I missing? https://share.getcloudapp.com/wbuex6N7 From your screencast it looks like you didn't switch to keyboard layout. With every character typed you should see IME window with changing hieroglyph suggestions. Thought that selecting this in the keyboard layout was enough. Never worked with Pinyin ;) However, still don't get IAEs. I would expect them in the console log. https://share.getcloudapp.com/12uElWbg Did you enable "Use Halfwidth punctuation" in keyboard layout menu? (In reply to Alexandr Miloslavskiy from comment #13) > Did you enable "Use Halfwidth punctuation" in keyboard layout menu? Yes. You mean the checkbox in the Mac keyboard layout setting dialog. Indeed there's something else required. The problem reproduces reliably for me and one other guy, but I can't reproduce it on 2 other machines. For me the problem didn't reproduce at all until I enabled "Use Halfwidth punctuation", but I also did some other things in between, and now after disabling "Use Halfwidth punctuation" the problem still reproduces for me. I'll try to figure what other step is required here. Created attachment 280610 [details]
Repro snippet
Improved repro scenario
I think I found it. Please refer to improved snippet. This also explains what the macOS bug is... The same problem occurs with words like 'glorified', 'amplified'. As a reminder, the same bug is visible when typing in default Terminal, especially with these steps: 1) Type 'xyz' 2) Set caret to beginning of string 3) Type 'modified' 4) Notice where caret is Thanks, with the new snippet I can reproduce it. Created attachment 280648 [details]
Native repro snippet
Use this snippet with the same steps as described inside Java snippet.
This snippet shows that the same problem occurs in native (also see previous comments about Terminal).
Compile with:
clang -Wno-deprecated-declarations -framework Cocoa "SWT_427882_macOS_IME_IAE.m" -o "SWT_427882_macOS_IME_IAE" && "./SWT_427882_macOS_IME_IAE"
Still reproducible on macOS 10.15; test snippet from Comment 16 gives: Exception in thread "main" java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:4850) at org.eclipse.swt.SWT.error(SWT.java:4784) at org.eclipse.swt.SWT.error(SWT.java:4755) at org.eclipse.swt.custom.DefaultContent.error(DefaultContent.java:682) at org.eclipse.swt.custom.DefaultContent.getLineAtOffset(DefaultContent.java:575) at org.eclipse.swt.custom.StyledText.getBoundsAtOffset(StyledText.java:3673) at org.eclipse.swt.custom.StyledText.showCaret(StyledText.java:10786) at org.eclipse.swt.custom.StyledText.handleCompositionChanged(StyledText.java:5973) at org.eclipse.swt.custom.StyledText.lambda$installListeners$2(StyledText.java:5825) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4385) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520) at org.eclipse.swt.widgets.IME.setMarkedText_selectedRange(IME.java:502) at org.eclipse.swt.widgets.Canvas.setMarkedText_selectedRange(Canvas.java:602) at org.eclipse.swt.widgets.Display.windowProc(Display.java:6422) at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method) at org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:59) at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:606) at org.eclipse.swt.widgets.Display.windowProc(Display.java:6016) at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:235) at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2150) at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2401) at org.eclipse.swt.widgets.Display.windowProc(Display.java:6136) at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5386) at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5522) at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method) at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:117) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3786) at Bug427882_StyledText_IME_IllegalArgument.main(Bug427882_StyledText_IME_IllegalArgument.java:55) New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/170823 Gerrit change https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/170823 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=2a9595e067812151c4c2b3df2bbcba7c10ddf3ae |