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

Not on FX application thread exception at shut down #4148

Closed
chimp1984 opened this issue Apr 8, 2020 · 4 comments
Closed

Not on FX application thread exception at shut down #4148

chimp1984 opened this issue Apr 8, 2020 · 4 comments

Comments

@chimp1984
Copy link
Contributor

Seems the recent changes by @stejbac making the UserThread thread safe causes this axception at shut down (shutdown done in IDE without closing Bisq window):

In BisqApp.java:153

new Thread(() -> {
                gracefulShutDownHandler.gracefulShutDown(() -> {
                    log.debug("App shutdown complete");
                });
            })
java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-6
	at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
	at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:424)
	at javafx.scene.Parent$3.onProposedChange(Parent.java:471)
	at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113)
	at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108)
	at javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:272)
	at javafx.scene.control.skin.LabeledSkinBase.lambda$new$11(LabeledSkinBase.java:220)
	at com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49)
	at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
	at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
	at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
	at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:104)
	at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111)
	at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
	at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:50)
	at javafx.beans.property.StringProperty.setValue(StringProperty.java:65)
	at javafx.scene.control.Labeled.setText(Labeled.java:147)
	at bisq.desktop.main.offer.offerbook.OfferBookView.lambda$initialize$6(OfferBookView.java:259)
	at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
	at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
	at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
	at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
	at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
	at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
	at javafx.collections.transformation.SortedList.sourceChanged(SortedList.java:111)
	at javafx.collections.transformation.TransformationList.lambda$getListener$0(TransformationList.java:106)
	at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
	at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
	at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
	at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
	at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
	at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
	at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
	at javafx.collections.transformation.FilteredList.sourceChanged(FilteredList.java:147)
	at javafx.collections.transformation.TransformationList.lambda$getListener$0(TransformationList.java:106)
	at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
	at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
	at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
	at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
	at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
	at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
	at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
	at javafx.collections.ModifiableObservableListBase.remove(ModifiableObservableListBase.java:183)
	at javafx.collections.ModifiableObservableListBase.remove(ModifiableObservableListBase.java:171)
	at java.base/java.util.Optional.ifPresent(Optional.java:172)
	at bisq.desktop.main.offer.offerbook.OfferBook$1.onRemoved(OfferBook.java:110)
	at bisq.core.offer.OfferBookService$1.lambda$onRemoved$2(OfferBookService.java:107)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at bisq.core.offer.OfferBookService$1.lambda$onRemoved$3(OfferBookService.java:102)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1378)
	at bisq.core.offer.OfferBookService$1.onRemoved(OfferBookService.java:102)
	at bisq.network.p2p.storage.P2PDataStorage.lambda$removeFromMapAndDataStore$16(P2PDataStorage.java:853)
	at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:804)
	at java.base/java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:425)
	at bisq.network.p2p.storage.P2PDataStorage.removeFromMapAndDataStore(P2PDataStorage.java:853)
	at bisq.network.p2p.storage.P2PDataStorage.removeFromMapAndDataStore(P2PDataStorage.java:828)
	at bisq.network.p2p.storage.P2PDataStorage.remove(P2PDataStorage.java:711)
	at bisq.network.p2p.P2PService.removeData(P2PService.java:822)
	at bisq.core.offer.OfferBookService.removeOffer(OfferBookService.java:184)
	at bisq.core.offer.OfferBookService.removeOfferAtShutDown(OfferBookService.java:207)
	at bisq.core.offer.OpenOfferManager.lambda$shutDown$4(OpenOfferManager.java:227)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at bisq.core.trade.TradableList.forEach(TradableList.java:136)
	at bisq.core.offer.OpenOfferManager.shutDown(OpenOfferManager.java:227)
	at bisq.core.app.BisqExecutable.gracefulShutDown(BisqExecutable.java:216)
	at bisq.desktop.app.BisqApp.lambda$stop$2(BisqApp.java:153)
@stejbac
Copy link
Contributor

stejbac commented Apr 9, 2020

I don't think my PR (#4122) to change the behaviour of UserThread has been merged yet, at least not into master. However, it does include a change to OpenOfferManager which should fix the above exception.

It looks like it was an unrelated change (to prevent a lockup on shutdown) on the 26th of March which replaced UserThread.runAfter(..) with new Thread(..).start() in BisqApp.java:153.

BTW, I noticed during testing of the above PR that a lockup-on-shutdown problem still exists when there are open offers, as the relevant branch of OpenOfferManager.shutDown passes the completeHandler continuation to UserThread::runAfter instead of executing it directly in the new thread created in BisqApp. I wasn't quite sure the best way to fix the issue at the time, as I'm not very familiar with that area of the code, so I left it.

@freimair
Copy link
Member

probably has been my change. Although I proposed a more final solution to the issue: bisq-network/projects#28

this most probably has been fixed by #4122! can be closed.

@stale
Copy link

stale bot commented Jul 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the was:dropped label Jul 11, 2020
@stale
Copy link

stale bot commented Jul 18, 2020

This issue has been automatically closed because of inactivity. Feel free to reopen it if you think it is still relevant.

@stale stale bot closed this as completed Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants