Unable to remove shape exception with screen painter

Custom indicators, trading strategies, data export and recording and more...
zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Unable to remove shape exception with screen painter

Post by zcsoka » Tue Nov 02, 2021 2:22 pm

Greetings,

In the latest version I started to get exceptions after removing a plugin with screenpainters, similar to:

Caused by: java.lang.IllegalArgumentException: Unable to remove shape -7568216178698742769 - was it added first? Removing twice?
    at velox.opengl.painter.layers.CanvasLayer.a(SourceFile:186)
    at velox.bookmap.gD.i(SourceFile:2440)
    at velox.bookmap.gD.a(SourceFile:2228)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)

I use the plugin, it works fine, afterwards I go to the configuration and click remove. Sometimes the drawings continue to draw and quite often I get the exception above. I have tried to set the screenpainter class to null, but did not help. Do I have to perform any specific steps to clearly wind down screen painter used plugins in the stop method? In the previous versions I never experienced similar issues. 
Thanks in advance

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Unable to remove shape exception with screen painter

Post by Svyatoslav » Tue Nov 02, 2021 2:27 pm

Consider logging every shape addition and removal that you are requesting from bookmap. My first suspicion is exactly what it complains about - removal of a shape that is either already removed or not added yet.

Also, could you clarify exact version and build numbers where it works fine and where it does not?

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Unable to remove shape exception with screen painter

Post by zcsoka » Tue Nov 02, 2021 3:01 pm

I suppose it is the removal, since I remove the add-on. I am not sure where it worked, but it does not work in 7.2.0 build 20. I did not have this issue in earlier builds, same version. 
The exception comes couple of seconds after the add-on is removed. Should be there any routine to get rid of the screen painter in the stop method?

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Unable to remove shape exception with screen painter

Post by Svyatoslav » Tue Nov 02, 2021 3:24 pm

Well, you should unregister whatever you register while being stopped, but the error looks like the opposite - not like you forgot to unregister, but more like you unregister something that was not registered.

Knowing a build number where it worked would help, cause I'd be able to check the changes. I don't remember anything relevant to your issue from the top of my head.

Unless you can find the build number (or maybe even if you can) logging every shape removal and addition to see if you actually remove something twice/ remove something that you didn't add or not would be helpful.

Also... Does that affect 7.3?

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Unable to remove shape exception with screen painter

Post by zcsoka » Tue Nov 02, 2021 10:24 pm

It was my fault, I have forgotten in the stop method to disable the messages (a false copy paste removed it). Adding:

api.sendUserMessage(ssp.getUserMessage(indicatorName, false));

solved the problem, thank you for your help and sorry for the false alarm.

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Unable to remove shape exception with screen painter

Post by zcsoka » Fri Nov 05, 2021 10:39 am

Hi Svyatoslav,

The issue seems to be present and I do not think it is in my code, but how Bookmap handles the screen painter. I could reproduce the issue as follows:
Add an add-on to NQ with screenpainter
Add an add-on to ES with screenpainter
Change tab to other instrument and change back to the first time. 

It always crashes, throws an error and I cannot continue, it comes again, so only exit helps.  By accident I have reported it many times via Bookmap, but in the next post I will post the exception.

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Unable to remove shape exception with screen painter

Post by zcsoka » Fri Nov 05, 2021 10:47 am

Code: Select all

 
20211105 10:34:35.126(UTC) ERROR: Exception while handling another exception
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at velox.api.layer1.common.j.b(SourceFile:1225)
at velox.api.layer1.common.j.c(SourceFile:1238)
at velox.bookmap.gD.a(SourceFile:1891)
at velox.bookmap.he.b(SourceFile:458)
at velox.opengl.painter.a.l(SourceFile:154)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.reflect.InvocationTargetException
at java.desktop/java.awt.EventQueue.invokeAndWait(EventQueue.java:1367)
at java.desktop/java.awt.EventQueue.invokeAndWait(EventQueue.java:1342)
at java.desktop/javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1480)
at velox.api.layer1.common.j.b(SourceFile:1223)
... 7 more
Caused by: java.lang.IllegalArgumentException: Unable to remove shape 7923742402847840574 - was it added first? Removing twice?
at velox.opengl.painter.layers.CanvasLayer.a(SourceFile:186)
at velox.bookmap.gD.i(SourceFile:2440)
at velox.bookmap.gD.a(SourceFile:2228)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:306)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at velox.ib.O.dispatchEvent(SourceFile:70)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117)
at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
at java.desktop/java.awt.Dialog.show(Dialog.java:1070)
at java.desktop/java.awt.Component.show(Component.java:1717)
at java.desktop/java.awt.Component.setVisible(Component.java:1664)
at java.desktop/java.awt.Window.setVisible(Window.java:1023)
at java.desktop/java.awt.Dialog.setVisible(Dialog.java:1005)
at velox.bookmap.qp.a(SourceFile:176)
at velox.bookmap.qp.b(SourceFile:114)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:306)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at velox.ib.O.dispatchEvent(SourceFile:70)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Unable to remove shape exception with screen painter

Post by Svyatoslav » Fri Nov 05, 2021 11:07 am

Hi, Could you please send me an example indicator that produces this error, so we can reproduce/debug? (directly over email is fine). Also, does that happen on 7.3?

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Unable to remove shape exception with screen painter

Post by zcsoka » Fri Nov 05, 2021 2:16 pm

An example can be the EMA Zones indicator from the marketplace, feel free to add a dev license for yourself. I could reproduce that with other plugins as well. 
Regarding 7.3, I will try later today.

zcsoka
Posts: 290
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 28 times

Re: Unable to remove shape exception with screen painter

Post by zcsoka » Fri Nov 05, 2021 6:27 pm

Tested with 7.3, the issue can be reproduced with that version too. 

Post Reply