Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(mac): Java does not appear to be 100% compatible with InputMethodKit #3935

Open
mcdurdin opened this issue Nov 23, 2020 · 34 comments
Open
Assignees
Labels
bug compatibility Issues in interactions between Keyman and a specific app or group of apps, e.g. incorrect output external Requires changes to other software programs in order to resolve mac/engine/ mac/
Milestone

Comments

@mcdurdin
Copy link
Member

This is a container issue for compatibility issues with Java on macOS.

The following may be related: https://youtrack.jetbrains.com/issue/JBR-1758

Related issues:

@mcdurdin mcdurdin added bug mac/ compatibility Issues in interactions between Keyman and a specific app or group of apps, e.g. incorrect output external Requires changes to other software programs in order to resolve mac/engine/ labels Nov 23, 2020
@mcdurdin mcdurdin added this to the P10S20 milestone Nov 23, 2020
mcdurdin added a commit that referenced this issue Nov 24, 2020
Relates to #3935.

This switches Java apps into legacy mode. However, Java itself will need
patching to support Keyman, as it makes assumptions about input methods,
including matching specific input methods by name, before enabling its
complex text support.

I am in process of submitting a bug report and may try and submit a
patch (although the process seems a little convoluted). It requires a
change to a single file, AWTView.m, with the following diff (against
JDK 16.0):

diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
index 3e80b5a6cf3..2ae1f4f3f12 100644
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
@@ -263,6 +263,16 @@ - (void) keyDown: (NSEvent *)event {
     fProcessingKeystroke = YES;
     fKeyEventsNeeded = YES;

+    if([(NSString *)kbdLayout containsString:@"keyman"]) {
+        // Keyman handles all key events; none should be
+        // passed through as default before Keyman processes them
+        fKeyEventsNeeded = NO;
+    }
     // Allow TSM to look at the event and potentially send back NSTextInputClient messages.
     [self interpretKeyEvents:[NSArray arrayWithObject:event]];

@@ -960,7 +989,9 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange

     if ((utf16Length > 2) ||
         ((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:codePoint]) ||
-        ((codePoint == 0x5c) && ([(NSString *)kbdLayout containsString:@"Kotoeri"]))) {
+        ((codePoint == 0x5c) && ([(NSString *)kbdLayout containsString:@"Kotoeri"])) ||
+        ([(NSString *)kbdLayout containsString:@"keyman"])
+        ) {
         aStringIsComplex = YES;
     }
@mcdurdin mcdurdin modified the milestones: P10S20, Waiting-external Nov 25, 2020
@mcdurdin
Copy link
Member Author

See http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8257650 for our submitted bug.

@mcdurdin
Copy link
Member Author

mcdurdin commented Oct 7, 2021

I've gone ahead and closed #174, #458 and #3243, to reduce duplication as they all pertain to the same basic problem.

Note that there may be additional information in those issues that we want to refer to later.

@Matt-SIL
Copy link

Have there been any developments with this issue? I just posted on the ELAN forum before seeing this.

https://archive.mpi.nl/forums/t/trouble-with-input-from-syllabic-orthography-keyboard/3468

@mcdurdin
Copy link
Member Author

We have not had any progress with this; it is a limitation in Java and we submitted an issue 4 years ago for it (https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8195675). Feel free to submit another bug to Oracle!

@Matt-SIL
Copy link

Ok, I'm not sure I know enough to submit a bug with all the technical info they need but I would live to tell them this potentially affects a large number of minority languages.

@mcdurdin
Copy link
Member Author

It's difficult -- I hope that bug reports from various people would help them to understand the scope. In theory we could submit a patch, but the amount of legwork that is required to do that seems daunting! (This seems to be a problem with quite a few large open source projects -- they develop policies and procedures which work for them but effectively lock out external contributors who already have to navigate huge technical complexity in order to submit patches, and the additional policy complexity just makes it too hard.)

@JuarezRC
Copy link

Hi @mcdurdin, I have a similar issue running the IPA(SIL) Keyboard on Mac. They keyboard works well everywhere, except for ELAN. Any recommendation where I should look for a solution?

@mcdurdin
Copy link
Member Author

@JuarezRC, yes, this is a long-standing issue. We are waiting for Java developers to fix things on their end -- Keyman is behaving correctly; Java (which ELAN is built on) is not. The two bug reports above have had no response from Oracle or any Java Development Kit developers; we may need to try and raise them in forums or Java dev mailing lists. We have not had the in-team capacity to chase these up until now.

Can I encourage you to also open a bug report or ask on the Java Discussion group (looks like awkward timing though as they are migrating their Discussion databases in the next couple of days -- may want to wait a week).

Other possible workarounds, even if not palatable -- mentioned for completeness:

  • Use ELAN on Windows, where AFAIK things work correctly.
  • Copy and paste text into ELAN

We will also have another go at contributing a patch to JDK when we find the capacity (@sgschantz this may be something you could look into?)

@JuarezRC
Copy link

Thanks! I will follow up on this.

@mcdurdin
Copy link
Member Author

@mcdurdin
Copy link
Member Author

@srl295 please review

@mcdurdin
Copy link
Member Author

See #3944 for sample patch

@srl295
Copy link
Member

srl295 commented Mar 1, 2024

PR: openjdk/jdk#17921

@mcdurdin
Copy link
Member Author

Some positive progress on this with openjdk, follow links above

@mcdurdin
Copy link
Member Author

See also https://community.software.sil.org/t/keyman-and-xlingpaper/8580/1 (presumably XMLMind which XLingPaper is based on)

@AndyBlack
Copy link

See also https://community.software.sil.org/t/keyman-and-xlingpaper/8580/1 (presumably XMLMind which XLingPaper is based on)

Yes, the XMLmind XL Editor (aka XXE) is written in Java and XLingPaper is a set of configuration files for it. The challenge we'll face is that most XLingPaper users are using an older version of XXE which still had a personal use license. The version they're using will not have the fix to the openjdk. Sigh.

@darcywong00 darcywong00 modified the milestones: A18S10, A18S11 Sep 14, 2024
@darcywong00 darcywong00 modified the milestones: A18S11, A18S12 Sep 28, 2024
@darcywong00 darcywong00 modified the milestones: A18S12, A18S13 Oct 11, 2024
@srl295
Copy link
Member

srl295 commented Oct 14, 2024

I've finally created a backport for v21 https://bugs.openjdk.org/browse/JDK-8342073 - I have a lot of questions about the process (it's literally been many years since I have done a backport for them) but it's in progress. If this goes well I'll replicate it back as far as I can.

@srl295
Copy link
Member

srl295 commented Oct 16, 2024

Requested backports for:

  • jdk8
  • jdk11
  • jdk17
  • jdk21

@darcywong00 darcywong00 modified the milestones: A18S13, A18S14 Oct 26, 2024
@srl295
Copy link
Member

srl295 commented Oct 26, 2024

Update^ All four of these have been tested on mac and found to fix the issue.

@AndyBlack
Copy link

Good news!
I'm not familiar with backports and how they work. I'm currently using Azul Zulu's JDK 17 (17.0.11+9; its Bundle name is Zulu 17.50.19). Does this mean that at some point Azul will include this fix for their Java 17 JDK and at that time I can get that version and then Keyman will work with my Java apps built using this?

@srl295
Copy link
Member

srl295 commented Oct 26, 2024 via email

@srl295
Copy link
Member

srl295 commented Oct 28, 2024

Ok 21 was merged! Others to follow.

@AndyBlack
Copy link

Yes, a jdk 17 package to test would be helpful. Since I wrote earlier, I've learned how to use jpackage to create installers.

If it's not too much trouble, a version 8 jre would also be nice to test (this would be for the XLingPaper configuration files that are for the XMLmind XML Editor I mentioned. here back in April. I could try swapping out the jre we're currently using with the new one and see if it runs as before, but also allows for Keyman keyboards.

@srl295
Copy link
Member

srl295 commented Oct 28, 2024

@AndyBlack I sent you a gchat and also a share link to a directory w/ zips for 17 and 8. I used "make images" to build it. Let me know if it works or not.

@AndyBlack
Copy link

@srl295 Thanks! It may be a day or two before I can test these.

@srl295
Copy link
Member

srl295 commented Nov 1, 2024

17 integrated

@darcywong00 darcywong00 modified the milestones: A18S14, A18S15 Nov 9, 2024
@darcywong00 darcywong00 modified the milestones: A18S15, A18S16 Nov 24, 2024
@mcdurdin mcdurdin moved this to Todo in Keyman Nov 28, 2024
@darcywong00 darcywong00 modified the milestones: A18S16, A18S17 Dec 7, 2024
@darcywong00 darcywong00 modified the milestones: A18S17, A18S18 Dec 21, 2024
@darcywong00 darcywong00 modified the milestones: A18S18, A18S19 Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compatibility Issues in interactions between Keyman and a specific app or group of apps, e.g. incorrect output external Requires changes to other software programs in order to resolve mac/engine/ mac/
Projects
Status: Todo
Development

No branches or pull requests

6 participants