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

stm32cubemx: Can't initiate JxBrowser engine #272342

Closed
asmir-abdulahovic opened this issue Dec 5, 2023 · 12 comments · Fixed by #280833
Closed

stm32cubemx: Can't initiate JxBrowser engine #272342

asmir-abdulahovic opened this issue Dec 5, 2023 · 12 comments · Fixed by #280833

Comments

@asmir-abdulahovic
Copy link
Contributor

asmir-abdulahovic commented Dec 5, 2023

Describe the bug

When clicking "GENERATE CODE" nothing happens, and I get the error from title in the console log.
I'm not familiar with java but I guess newer cubemx versions require some browser like functionality which failed to init within java runtime due missing .so dependencies.

Startup Info:

log4j user configuration file not found: /home/akill/.stm32cubemx/log4j2.xml
Configure log4j with default settings from jar:file:/nix/store/3mv4p1lz0xmmy5cb3zz9d74vsmqyj58m-stm32cubemx-6.9.2/opt/STM32CubeMX/STM32CubeMX!/log4j/log4j2.stm32cubemx.xml
2023-12-05 21:06:19,347 [INFO] MicroXplorer:98 - [MX] MX Start == 60807442279392
2023-12-05 21:06:19,348 [INFO] MicroXplorer:653 - Detected Java Version = 17.0.7
2023-12-05 21:06:19,620 [INFO] ApplicationProperties:184 - Using Application install path: /nix/store/3mv4p1lz0xmmy5cb3zz9d74vsmqyj58m-stm32cubemx-6.9.2/opt/STM32CubeMX
2023-12-05 21:06:19,632 [INFO] DbMcusXml:78 - Set database path to: /nix/store/3mv4p1lz0xmmy5cb3zz9d74vsmqyj58m-stm32cubemx-6.9.2/opt/STM32CubeMX//db//mcu/
2023-12-05 21:06:19,632 [INFO] ApiDb:274 - Set plugin database path to: /nix/store/3mv4p1lz0xmmy5cb3zz9d74vsmqyj58m-stm32cubemx-6.9.2/opt/STM32CubeMX//db//plugins/boardmanager/

Relevant error log:

2023-12-05 21:06:23,473 [ERROR] JxBrowserEngine:69 - Can't initiate JxBrowser engine com.teamdev.jxbrowser.engine.MissingDependencyException: Missing dependencies have been detected:
	libGLESv2.so => libXext.so.6 libxcb.so.1 libX11.so.6 
	chromium => libXfixes.so.3 libasound.so.2 libXcomposite.so.1 libcairo.so.2 libxcb.so.1 libpango-1.0.so.0 libgio-2.0.so.0 libatspi.so.0 libatk-bridge-2.0.so.0 libXext.so.6 libdrm.so.2 libnspr4.so libxkbcommon.so.0 libnssutil3.so libcups.so.2 libgbm.so.1 libglib-2.0.so.0 libsmime3.so libatk-1.0.so.0 libgobject-2.0.so.0 libexpat.so.1 libdbus-1.so.3 libXdamage.so.1 libXrandr.so.2 libnss3.so libX11.so.6 
	libtoolkit.so => libgtk-3.so.0 libglib-2.0.so.0 libgobject-2.0.so.0 libX11.so.6 libgdk-3.so.0 
Exception in thread "Thread-3" java.lang.NullPointerException: Cannot invoke "javax.swing.JComponent.setVisible(boolean)" because "this.webAppContainer" is null
	at com.st.microxplorer.plugins.userauth.UserAuth.activatePlugin(UserAuth.java:200)
	at com.st.microxplorer.maingui.MainFrame.lambda$initialization$0(MainFrame.java:189)
	at java.base/java.lang.Thread.run(Thread.java:833)
java.lang.NullPointerException: Cannot invoke "com.teamdev.jxbrowser.browser.Browser.mainFrame()" because "this.browser" is null
	at com.st.microxplorer.plugins.userauth.WebApp.isAuthenticated(WebApp.java:615) ~[?:?]
	at com.st.microxplorer.plugins.userauth.UserAuth.handleAuthentication(UserAuth.java:452) ~[?:?]
	at com.st.microxplorer.plugins.userauth.UserAuth.getSpecificTask(UserAuth.java:259) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.gui.ProjectChoiceTab.save(ProjectChoiceTab.java:1349) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.ProjectManagerView.generateCode(ProjectManagerView.java:1068) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.ProjectManagerView.getSpecificTask(ProjectManagerView.java:729) ~[?:?]
	at com.st.microxplorer.maingui.RibbonBar$1.actionPerformed(RibbonBar.java:363) ~[STM32CubeMX:?]
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972) ~[?:?]
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313) ~[?:?]
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) ~[?:?]
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) ~[?:?]
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) ~[?:?]
	at java.awt.Component.processMouseEvent(Component.java:6626) ~[?:?]
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3389) ~[?:?]
	at java.awt.Component.processEvent(Component.java:6391) ~[?:?]
	at java.awt.Container.processEvent(Container.java:2266) ~[?:?]
	at java.awt.Component.dispatchEventImpl(Component.java:5001) ~[?:?]
	at java.awt.Container.dispatchEventImpl(Container.java:2324) ~[?:?]
	at java.awt.Component.dispatchEvent(Component.java:4833) ~[?:?]
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948) ~[?:?]
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575) ~[?:?]
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516) ~[?:?]
	at java.awt.Container.dispatchEventImpl(Container.java:2310) ~[?:?]
	at java.awt.Window.dispatchEventImpl(Window.java:2780) ~[?:?]
	at java.awt.Component.dispatchEvent(Component.java:4833) ~[?:?]
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) ~[?:?]
	at java.awt.EventQueue$4.run(EventQueue.java:722) ~[?:?]
	at java.awt.EventQueue$4.run(EventQueue.java:716) ~[?:?]
	at java.security.AccessController.doPrivileged(AccessController.java:399) ~[?:?]
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) ~[?:?]
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97) ~[?:?]
	at java.awt.EventQueue$5.run(EventQueue.java:746) ~[?:?]
	at java.awt.EventQueue$5.run(EventQueue.java:744) ~[?:?]
	at java.security.AccessController.doPrivileged(AccessController.java:399) ~[?:?]
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) ~[?:?]
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:743) ~[?:?]
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) ~[?:?]
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) ~[?:?]
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) ~[?:?]
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) ~[?:?]
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) ~[?:?]
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) ~[?:?]

Steps To Reproduce

  • Spawn shell with stm32cubemx using nix shell nixpkgs#stm32cubemx --impure.
  • Create CubeMX project
  • Generate Code

Expected behavior

Generated project folder with confirmation window.

Notify maintainers

@angaz @wucke13

Metadata

❯ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.2, NixOS, 24.05 (Uakari), 24.05.20231127.8cfef69`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos"`
 - channels(akill): `"home-manager, nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@asmir-abdulahovic
Copy link
Contributor Author

asmir-abdulahovic commented Dec 5, 2023

After further investigation I think CubeMX is trying to execute binaries found in ~/.stm32cubemx/.jxbrowser-7.30.2/Chromium, which were downloaded during the first startup.
I'm not sure if this is fixable without FHS env.

@liarokapisv
Copy link
Contributor

This bug kind of kills my workflow. Has anyone investigated further? I will try to work things out during the weekend.

@asmir-abdulahovic
Copy link
Contributor Author

I've kinda got it to work using FHS env.

Only issue I have is that the CubeMX now requires login for code generation, and the login window (embedded browser) takes a while to appear on Wayland (Sway) and uses a lot of the CPU for no reason, while it appears OK on X11.
Though you only need to login once, and than it works normaly.

I have updated package here :
https://git.project-cloud.net/asmir/nixos_flake_config/src/branch/master/packages/stm32cubemx/default.nix

I guess I shold make a pull request out of it.

@angaz
Copy link
Member

angaz commented Jan 9, 2024

CubeMX now requires login for code generation
It is sad to see ST hurt us like this.

I would appreciate a PR, it seems to be a good solution. You can ping me and I'll have a look.
Not really sure what we can do about the wait and high CPU. I think getting the package usable again, and then trying to fix that problem sounds like a good way to progress.

@liarokapisv
Copy link
Contributor

liarokapisv commented Jan 9, 2024

Thanks for the fast replies! @asmir-abdulahovic Do you recall how you approached debugging the issue?

EDIT: Turns out I get a similar but not identical error:

2024-01-09 23:02:39,925 [ERROR] JxBrowserEngine:70 - Can't initiate JxBrowser engine com.teamdev.jxbrowser.engine.ChromiumBinariesDeliveryException: com.teamdev.jxbrowser.engine.ChromiumBinariesDeliveryException: Failed to extract Chromium binaries into /home/veritas/.stm32cubemx/.jxbrowser-7.35.1/Chromium
Exception in thread "Thread-3" java.lang.NullPointerException: Cannot invoke "javax.swing.JComponent.setVisible(boolean)" because "this.webAppContainer" is null
	at com.st.microxplorer.plugins.userauth.UserAuth.activatePlugin(UserAuth.java:201)
	at com.st.microxplorer.maingui.MainFrame.lambda$initialization$0(MainFrame.java:190)
	at java.base/java.lang.Thread.run(Thread.java:1583)

This occurs at startup then clicking generate fails due to missing browser instance.

Running the jar directly with JxBrowser logs gives:

0:28:49.803 INFO Linux 6.6.0-asahi
0:28:49.804 INFO Java 17.0.7  64-bit (aarch64)
0:28:49.804 INFO JxBrowser version: 7.30.2
0:28:49.804 INFO Chromium version: 108.0.5359.215
0:28:49.804 INFO Temp folder: /tmp
0:28:49.845 DEBUG Creating target directory...
0:28:49.845 DEBUG Acquiring an exclusive lock...
0:28:49.845 DEBUG Verifying Chromium binaries...
0:28:49.845 DEBUG Using ChromiumVerifierLinux verifier...
0:28:49.845 DEBUG Verifying /home/veritas/.stm32cubemx/.jxbrowser-7.30.2/Chromium/locales/nl.pak...
0:28:49.845 DEBUG Verifying /home/veritas/.stm32cubemx/.jxbrowser-7.30.2/Chromium/locales/nl.pak... [FAIL] File does not exist
0:28:49.845 DEBUG Verifying Chromium binaries... [FAIL]
0:28:49.845 DEBUG Finding Chromium binaries in JARs...
0:28:49.845 DEBUG Finding chromium-linux64-arm.7z...
0:28:49.846 DEBUG Finding chromium-linux64-arm.7z... [FAIL]
0:28:49.846 DEBUG Releasing the exclusive lock...

which is not much.

nix-info:

 - system: `"aarch64-linux"`
 - host os: `Linux 6.6.0-asahi, NixOS, 24.05 (Uakari), 24.05.20231222.6df37dc`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

@asmir-abdulahovic
Copy link
Contributor Author

asmir-abdulahovic commented Jan 9, 2024

@angaz
thanks, will make PR over the weekend most likely

@liarokapisv
I got simmilar error when I wanted to keep pached ~/.stm32cubemx/.../Chromium by setting chattr +i.
So cube didn't get permissions to extract Chromium and failed.
Maybe try to remove/backup ~/.stm32cubemx and try again.

@liarokapisv
Copy link
Contributor

I have deleted ~/.stm32cubemx multiple times while doing these checks, and it doesn't change anything.

@asmir-abdulahovic
Copy link
Contributor Author

asmir-abdulahovic commented Jan 9, 2024

Than please try to run it with steam-run, maybe extractor is missing something too.
Also please try my package linked above. It's a closed source app so we are verry limited...

Edit:
Now I see you are using aarch64, I'm not sure if Cube will support that even though it's java.
Please check what kind of binary do you get in ~/.stm32cubemx/.../Chromium

@liarokapisv
Copy link
Contributor

liarokapisv commented Jan 9, 2024

There are no binaries under the folder, only the lock file. JxBrowser does seem to support aarch64 linux but maybe there is something wrong at the cubemx side. Thanks for your help!

@asmir-abdulahovic
Copy link
Contributor Author

asmir-abdulahovic commented Jan 9, 2024

JxBrowser seems packed into CubeMX.

0:28:49.846 DEBUG Finding chromium-linux64-arm.7z... [FAIL]

Maybe indicates that they didn't put arm version.

@liarokapisv
Copy link
Contributor

liarokapisv commented Jan 9, 2024

Yea, that is possible. Thanks for the help!

EDIT: It seems that the .7z bundle that JxBrowser provides is corrupted for linux arm.

@ajs124
Copy link
Member

ajs124 commented Jan 11, 2024

Coincidentally, I also tried to get this running last week inside an FHS env, but even with (basically) all dependencies in there (and in x86_64), one of the chromium child processes crashed in some udev function.

It also tried to load some very old libraries like libgcrypt.so.11, for some reason.

Just patching our own chromium in there and preventing it from modifying it might be a better solution, if it can be made to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants