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

Upgrade JFoenix to v9.0.10 #4443

Merged
merged 1 commit into from
Aug 31, 2020
Merged

Conversation

ghubstan
Copy link
Contributor

@ghubstan ghubstan commented Aug 27, 2020

This PR upgrades JFoenix from v9.0.6 to v9.0.10, to avoid an NPE thrown when registering a dispute agent in an arbitrator (regtest) desktop's account view.

The JFoenix com.jfoenix.adapters.ReflectionHelper class has a getFieldContent method that silently swallows a Throwable and returns null. After clicking ALT-D or ALT-N in the an arbitrator's desktop -> accounts view (register dispute agents) a private field cannot be accessed via reflection, and bisq.desktop.components.JFXTextFieldSkinBisqStyle#updateTextPos throws an NPE.

1-UI-Error

Aug-27 12:59:45.970 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: Uncaught Exception from thread JavaFX Application Thread 
Aug-27 12:59:45.970 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: throwableMessage= null 
Aug-27 12:59:45.970 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: throwableClass= class java.lang.NullPointerException 
Aug-27 12:59:45.971 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: Stack trace:
java.lang.NullPointerException
	at bisq.desktop.components.JFXTextFieldSkinBisqStyle.updateTextPos(JFXTextFieldSkinBisqStyle.java:95)
	at bisq.desktop.components.JFXTextFieldSkinBisqStyle.layoutChildren(JFXTextFieldSkinBisqStyle.java:79)
	at javafx.scene.control.Control.layoutChildren(Control.java:601)
	at javafx.scene.Parent.layout(Parent.java:1204)
	at javafx.scene.Parent.layout(Parent.java:1211)
	at javafx.scene.Parent.layout(Parent.java:1211)
	at javafx.scene.Scene.doLayoutPass(Scene.java:576)
	at javafx.scene.Scene.preferredSize(Scene.java:1748)
	at javafx.scene.Scene$2.preferredSize(Scene.java:393)
	at com.sun.javafx.scene.SceneHelper.preferredSize(SceneHelper.java:66)
	at javafx.stage.Window$12.invalidated(Window.java:1086)
	at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
	at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
	at javafx.stage.Window.setShowing(Window.java:1174)
	at javafx.stage.Window.show(Window.java:1189)
	at javafx.stage.Stage.show(Stage.java:273)
	at bisq.desktop.main.overlays.Overlay.display(Overlay.java:538)
	at bisq.desktop.main.overlays.windows.UnlockDisputeAgentRegistrationWindow.show(UnlockDisputeAgentRegistrationWindow.java:85)
	at bisq.desktop.main.account.register.AgentRegistrationView.onTabSelection(AgentRegistrationView.java:121)
	at bisq.desktop.main.account.AccountView.loadView(AccountView.java:269)
	at bisq.desktop.main.account.AccountView.lambda$initialize$0(AccountView.java:114)
	at bisq.desktop.Navigation.lambda$navigateTo$1(Navigation.java:138)
	at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:804)
	at java.base/java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:425)
	at bisq.desktop.Navigation.navigateTo(Navigation.java:138)
	at bisq.desktop.Navigation.navigateTo(Navigation.java:103)
	at bisq.desktop.main.account.AccountView.lambda$initialize$1(AccountView.java:132)
	at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Scene$KeyHandler.process(Scene.java:4058)
	at javafx.scene.Scene$KeyHandler.access$1500(Scene.java:4004)
	at javafx.scene.Scene.processKeyEvent(Scene.java:2121)
	at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2595)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(GlassViewEventHandler.java:248)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
	at com.sun.glass.ui.View.handleKeyEvent(View.java:547)
	at com.sun.glass.ui.View.notifyKey(View.java:971)
	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
	at java.base/java.lang.Thread.run(Thread.java:832)

The NPE follows the failure to create a textNode instance using reflection, in the JFXTextFieldSkinBisqStyle constructor:
textNode = ReflectionHelper.getFieldContent(TextFieldSkin.class, this, "textNode");

If this happens, the UI becomes unusable -- many views are blank.

3-BlankSettings

4-BlankDAO

This problem has not been reproduced when running the bisq-desktop cmd below from a Linux (Ubuntu 20) bash shell:

$ ./bisq-desktop --appName=bisq-BTC_REGTEST_Arb_dao --appDataDir=<project-path>/apitest/build/resources/main/bisq-BTC_REGTEST_Arb_dao --nodePort=4444 --rpcBlockNotificationPort=5121 --rpcUser=apitest --rpcPassword=apitest --rpcPort=19443 --daoActivated=true --fullDaoNode=true --seedNodes=localhost:2002 --baseCurrencyNetwork=BTC_REGTEST --useDevPrivilegeKeys=true --useLocalhostForP2P=true --genesisBlockHeight=111 --genesisTxId=30af0050040befd8af25068cc697e418e09c2d8ebd8d411d2240591b9ec203cf

The same bisq-desktop cmd run by :apitest (using a java ProcessBuilder) reproduces the NPE every time. We need to be able to register dispute agents from an arbitration node started by any API test case.

This commit & PR upgrades JFoenix from v9.0.6 to v9.0.10, to avoid an
NPE thrown when registering a DisputeAgent in an arbitartor (regtest)
desktop's account view.

The JFoenix com.jfoenix.adapters.ReflectionHelper class has a getField
method that silently swallows a Throwable and returns null.  After
clicking ALT-D or ALT-N in the an arbitrator's desktop -> accounts view
(to register dispute agents) a private field cannot be accessed via
reflection, and bisq.desktop.components.JFXTextFieldSkinBisqStyle#updateTextPos()
throws an NPE.

The cause of the NPE is due to a failure to create the textNode value
in the JFXTextFieldSkinBisqStyle constructor:
 textNode = ReflectionHelper.getFieldContent(TextFieldSkin.class, this, "textNode");

If this happens,the UI becomes unusable -- many views are blank.
@chimp1984
Copy link
Contributor

Does the update solve the issue? It might be that its some security policy violation if you start the app from another process. If so I expect there might follow more issues. I don't know the details of your setup though.

@ghubstan
Copy link
Contributor Author

Does the update solve the issue? It might be that its some security policy violation if you start the app from another process. If so I expect there might follow more issues. I don't know the details of your setup though.

Yes, the upgrade does solve the issue. Why it does is something I have not yet learned from examining JFoenix src and JFoenix commit history. There are also problems stepping through src in the debugger below com.jfoenix.adapters.ReflectionHelper, in jdk.internal.*.

Not being able to find the answer directly from the JFoenix src made me fall back to others' reports. There are statements about JFoenix not being compatible with JDK 11+: an open JFoenix PR, and this stackoverflow post describing the same problem I see (using JDK 11). JFoenix Issue 995 shows others seeing the same bug, with some upgrading and passing jvm --add-opens options to work around it. I just needed to upgrade to resolve the issue.

JFoenix is still active, but not very. I think Bisq will be forced to upgrade this dependency for JDK14, but JFoenix might be gradually removed in stages, first by reducing the dependency on reflection in our cloned JFoenix code. There is an example of how to do some of that in PR 1110's single commit.

@chimp1984
Copy link
Contributor

Thanks for the details! We should try to get rid of that library...

utACK

Copy link
Member

@sqrrm sqrrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@sqrrm sqrrm merged commit 136da0c into bisq-network:master Aug 31, 2020
@sqrrm sqrrm added this to the v1.3.8 milestone Aug 31, 2020
@ghubstan ghubstan deleted the upgrade-jfoenix branch September 1, 2020 13:25
@ripcurlx
Copy link
Contributor

ripcurlx commented Sep 2, 2020

@ghubstan I'll revert this PR as I found a couple of issues during quick smoke testing. They should be fixable, but I don't have time to do it before v1.3.8. Could you please re-open this PR after the release branch for v1.3.8 is created?

Bildschirmfoto 2020-09-02 um 15 25 14
Bildschirmfoto 2020-09-02 um 15 24 52
Bildschirmfoto 2020-09-02 um 15 24 39

@ghubstan
Copy link
Contributor Author

ghubstan commented Sep 2, 2020

@ghubstan I'll revert this PR as I found a couple of issues during quick smoke testing. They should be fixable, but I don't have time to do it before v1.3.8. Could you please re-open this PR after the release branch for v1.3.8 is created?

Bildschirmfoto 2020-09-02 um 15 25 14
Bildschirmfoto 2020-09-02 um 15 24 52
Bildschirmfoto 2020-09-02 um 15 24 39

I will

@ghubstan
Copy link
Contributor Author

ghubstan commented Sep 2, 2020

Note: any jfoenix upgrade needs to be tested on JDK 10 and 11 (and 12+?).

@ripcurlx
Copy link
Contributor

ripcurlx commented Sep 3, 2020

Note: any jfoenix upgrade needs to be tested on JDK 10 and 11 (and 12+?).

As long as we need to stick to JDK 10 to create the release binaries, unfortunately yes.

@ghubstan
Copy link
Contributor Author

@ripcurlx I haven't been able to reproduce the JFX build KV related error you reported, running JDK 10 and OpenJDK 12 (with upgraded jfoenix lib).

Besides trying to set a password, what else were you doing when this happened?
What were you doing with that acct salt value?

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

Successfully merging this pull request may close these issues.

4 participants