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

[feature] Don't consume CPU when idle #2030

Closed
aj3423 opened this issue Oct 9, 2023 · 15 comments
Closed

[feature] Don't consume CPU when idle #2030

aj3423 opened this issue Oct 9, 2023 · 15 comments
Labels
bug GUI Issues in jadx-gui module need help

Comments

@aj3423
Copy link

aj3423 commented Oct 9, 2023

Describe your idea

It seems there is a background job running all the time, it consumes CPU. And the memory usage on the bottom bar changes all the time.

I saw from other thread that it's indexing. But I have already opened files I need, just want to stay at that page and spend some time reading the source, no more indexing is necessary.

Is it possible to disable this background job with an option in preference?

Thanks.

@skylot
Copy link
Owner

skylot commented Oct 9, 2023

@aj3423 this is not normal behavior.
Jadx shouldn't run any long background tasks outside of loading, searching or manually enabled Auto start background decompilation option in preferences.
Does this issue appear only for one apk? If so, please share that apk.
Also, share jadx version and jdk version (from about window), and try latest unstable build.

@skylot skylot added bug GUI Issues in jadx-gui module waiting for reply and removed new feature labels Oct 9, 2023
@aj3423
Copy link
Author

aj3423 commented Oct 11, 2023

@skylot I can confirm the CPUs goes very high after global searching, and it goes down back if the window goes to background or even being resized. This happens with any apk, the attached is a helloworld apk generated by android studio, same problem.
app-debug.apk.zip

To reproduce:

  1. open the apk in jadx-gui
  2. global search with ctrl + shift + f, type "a", open any file
  3. the cpu goes high (4 or)
  4. minimize or resize jadx, or just move mouse into the tab area that mark in red, then the cpu goes back down
    image

Don't know if it's os specific, I'm on Fedora 38 XFCE. Jadx was built from the latest source:

git log -1
commit d129be7e863353252f4ed78f6bc208544fbe7921
Date:   Mon Oct 9 19:46:51 2023 +0200

@aj3423
Copy link
Author

aj3423 commented Oct 22, 2023

I switched to KDE from XFCE, the problem still exists. Sometimes the cursor is changing all the time while high CPU.

V_20231022_084511_ES3.mp4

@skylot
Copy link
Owner

skylot commented Oct 22, 2023

@aj3423 sorry, but I can't reproduce this issue 🙁
It looks like a rendering problem, so using latest JRE may help.
Also, disabling bottom memory indicator (menu View->Show memory usage bar) may help.

Anyway, I will keep this issue open for some time, maybe someone else can reproduce and fix this issue.

@aj3423
Copy link
Author

aj3423 commented Oct 22, 2023

@skylot Neither hiding memory bar nor changing java version works. But I tried changing the theme, seems the problem is gone as long as I use the default them, and if I choose any other theme, the CPU goes high again.
image

@skylot
Copy link
Owner

skylot commented Oct 23, 2023

@aj3423 this means that FlatLaf causing this issue, or jadx uses it incorrect 🙁
Just in case, please try FlatLaf Demo, and check if it causes high CPU usage.

@aj3423
Copy link
Author

aj3423 commented Oct 23, 2023

@skylot Seems the problem also exists in FlatLaf Demo, I fired an issue there and I'll feedback here later.

@DevCharly
Copy link

I've analyzed the problem in FlatLaf Demo.
It is a bug in Java 17+ that occurs also in Metal L&F and under special conditions (right-to-left component orientation, text field, baseline layout). See JFormDesigner/FlatLaf#755 (comment) for details.

I'm not sure whether the problem in jadx is the same as in FlatLaf Demo.

@aj3423 could you capture some thread dumps of jadx (while CPU load is high)?
Java includes a command line tool called jstack that dumps stack of running Java app.
See: https://www.baeldung.com/java-thread-dump
It would be good to have several thread dumps (maybe 5 - 10) to find the cause of the CPU load.

@aj3423
Copy link
Author

aj3423 commented Nov 6, 2023

@DevCharly Here are 10 logs captured with sleep 3 && jstack -l 92032 > 1.log, during the 3 seconds, I activated the Jadx window to make sure it's consuming CPU, please check them out.
10 logs.zip

@DevCharly
Copy link

All 10 logs show that jadx is repainting all the time...

In the meantime I was able to reproduce the issue (on Win11 and on Ubuntu).
It has something to do with line wrapping.
After enabling "Line Wrap" in editor context menu, CPU/GPU load goes up.

@aj3423 have you enabled line wrapping?
If yes, does CPU load go down if you disable line wrapping?

In the debugger I see that one of the tabbed panes is recalculating layout while repainting, which seems to cause a new repaint, which results in endless relayout and repaint...

Don't know the exact reason.

Since FlatLaf 3.2.2, this seems to be "fixed".
The commit d129be7 that @aj3423 uses, uses FlatLaf 3.2.1.

@aj3423 please use latest jadx commit.

@skylot
Copy link
Owner

skylot commented Nov 7, 2023

It has something to do with line wrapping.

@DevCharly thanks! Indeed, with line wrapping enabled, I am also able to reproduce this issue. Although I also need to make jadx window inactive, and after I focus window again CPU load goes up.
I am using latest jadx commit which uses FlatLaf 3.2.5 (on Linux with Wayland, Java 17).

@aj3423
Copy link
Author

aj3423 commented Nov 8, 2023

@DevCharly Indeed it's the LineWrap causing the CPU problem, after disabling it, the CPU never goes up again.
But then I tried the latest Jadx, which uses FlatLaf 3.2.5, the problem still exists with LineWrap enabled.
Here are 5 logs captured with latest Jadx a989fa7
5 logs.zip

DevCharly added a commit to JFormDesigner/FlatLaf that referenced this issue Dec 30, 2023
…d tabbed panes (top and bottom tab placement) and RSyntaxTextArea (with enabled line-wrapping) as tab content (see skylot/jadx#2030)

instead of using `BasicTabbedPaneUI.TabbedPaneLayout.layoutContainer()`, now layouting all components ourself and avoid double moving/resizing of some components
@DevCharly
Copy link

fixed with latest FlatLaf 3.3-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

Could you test that snapshot? Thanks.
Plan to release FlatLaf 3.3 in the next days...

@skylot
Copy link
Owner

skylot commented Jan 8, 2024

@DevCharly issue fixed for me 🎉 Thank you 👍

@skylot
Copy link
Owner

skylot commented Jan 11, 2024

Fixed by updating FlatLaf to version 3.3.
To check, try latest unstable build.

@skylot skylot closed this as completed Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug GUI Issues in jadx-gui module need help
Projects
None yet
Development

No branches or pull requests

3 participants