Reporting focus problems

This article describes how to report issues with focus in IntelliJ based IDEs. If possible, perform all of the steps below. However, you can also provide just the basic info by skipping the bullet points and only following the numbers:

  1. Make sure IDE is in internal mode
  2. Open “Settings | Keymap” and assign a shortcut to “Internal Actions | UI | Dump Focusable Component Hierarchy”
  3. Reproduce the problem
  4. Once the focus is lost, determine what component is focused: 
    1. Invoke “Dump Focusable Component Hierarchy” with a shortcut
    2. Scroll down
    3. Press “Close and copy into the clipboard”
    4. Create a new issue in YouTrack
    5. Paste the info from the clipboard into the issue description
  • Optional: enable “Internal Actions | UI | Start focus debugger” and provide a screencast or a screenshot of how focus lost happens
  • Optional: check if the problem persists when using OpenJDK 11 as boot JDK. Use Choose Runtime plugin to switch
  • Extra helpful: Collect JDK logs (instruction below)

How to collect JDK logs

The aim is to determine what’s wrong with the focus events. An approach described below is based on comparing focus events between the two IDE builds - broken and working.

      1. Get the logging.properties file

      2. Specify the path to the downloaded file in the IDE “.vmoptions” file (Help | Edit Custom VM Options):

-Djava.util.logging.config.file=/Users/<username>/logging.properties

      3. Run the IDE from the console

The console should become flooded with focus events. Note that events are produced every time when focused component changes. In case you don’t see them, go to the section Setting up “logging.properties” below

      4. Recreate the problem. Every time a focus event appears, copy it to a text file

      5. Repeat steps 2-4 on IDE instance that isn’t affected by the issue (use some of the previous builds - see "Other Versions" section on IDE download page, or roll back if you use Toolbox)

      6. Compare focus events during normal and buggy scenarios. Likely you’ll notice that some events are missing when the bug happens - that’s the key that will help to fix it. See an example of an investigation

      7. Once finished, add tag focus-info-collected to the issue so the responsible developers can find and fix it

Setting up “logging.properties”

You should only follow this section if referred from the step 3 of the instruction above.

  1. Copy “logging.properties” file from any JDK 11 distribution (usually stored under “conf” folder).
  2. Modify “logging.properties”:
  • Set one of the handlers:
handlers= java.util.logging.ConsoleHandler

or

handlers= java.util.logging.FileHandler
  • Set logging level: 
java.util.logging.ConsoleHandler.level = ALL
  • Add component to the end (if needed, you can find other components in java.awt.Component - eventLog, focusLog, etc):
java.awt.focus.Component.level = ALL
sun.lwawt.focus.LWComponentPeer.level = ALL
java.awt.focus.DefaultKeyboardFocusManager.level = ALL

For reference, see this link.

Please sign in to leave a comment.

Have more questions?

Submit a request