B4J Question Resumable sub already completed

Blueforcer

Well-Known Member
Licensed User
Longtime User
im still fighting for many days to solve this problem. Unfortunally i dont know how :(. Maybe someone can help me
Im getting following error:

B4X:
Caused by: java.lang.RuntimeException: Resumable sub already completed
    at anywheresoftware.b4a.keywords.Common.WaitFor(Common.java:1041)
    at de.awtrix.main$ResumableSub_processPlugins.resume(main.java:2126)
    at de.awtrix.main._processplugins(main.java:2096)
    at de.awtrix.main._plugin_pluginschanged(main.java:1908)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)

this are the subs:
B4X:
Sub plugin_PluginsChanged 'Event from PluginLib
    If Matrix.isConnected=False Then Return
    processPlugins
End Sub

Sub processPlugins
    tickTimer.Enabled=False
    appTimer.Enabled=False
    pluginList.Clear
    pluginList= plugin.GetAvailablePlugins
    pluginList.Sort(True)
    wait for (oAuthHelper.Initialize) complete
    polling.getPollApps
    reloadPlugins
    refreshApplist
    Wait For (updateAll) complete
    If firstTime Then
        firstTime =False
        logger.write("-----------------------------")
        logger.write("Awtrix Ready - Start")
        logger.write("-----------------------------")
        If Not(Helper.offlineMode) Then updateTimer.Enabled=True
        appTimer.Enabled=True
        AppTimerRunning=True
        ChangeApp(0,"",False)
    End If
End Sub
 
Last edited:

Blueforcer

Well-Known Member
Licensed User
Longtime User
So far its running, big thanks.
but as mentioned before, it only occurred sporadically. I will try to trigger it for now:)
Can you upload the sources in a new branch on github?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
The reason I don't update it on github is because your version uses a completely different system (you make the check for new plugins calls yourself, while the original library did it automatically). I'll attach it here for reference.
 

Attachments

  • ABPlugin1.26src.zip
    12.4 KB · Views: 261
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
You could push it as a completely different branch, without touching the master branch/sources.
Anyway, thank you very much!
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
while it runs good on a PC, I get sporadically this new error on Raspberry.
Does this have anything to do with the lib?

B4X:
java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.ab.abplugin.ABPlugin.RunPlugin(ABPlugin.java:375)
    at de.awtrix.main._getplugininfos(main.java:1633)
    at de.awtrix.oauthhelper$ResumableSub_Initialize.resume(oauthhelper.java:260)
    at de.awtrix.oauthhelper._initialize(oauthhelper.java:199)
    at de.awtrix.main$ResumableSub_processPlugins.resume(main.java:2140)
    at de.awtrix.main._processplugins(main.java:2109)
    at de.awtrix.main._plugin_pluginschanged(main.java:1921)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.BA$3.run(BA.java:247)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:153)
    at de.awtrix.main._appstart(main.java:215)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at de.awtrix.main.main(main.java:28)
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
@Erel
Can you explain to me what "Resumable sub already completed" means exactly?
I found a different point in my app with this exeption.

Im loading a json from the internet in a resumable sub. The return value is always a map
This works favless on the main tasks. But as soon as i trigger it from the website (jServer, websocket) i get this error.
I used you thread log output:
Main tasks: Thread[main,5,main]
Website: Thread[pool-2-thread-1,5,main]

the website doesnt contains the wait for request directly. It just trigger the same sub as my main tasks. and there are some few sub in between before the download will start.
The crazy thing is, i cant reproduce it each time. Sometime it works and sometime not
 
Last edited:
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
What's your recommendation?
should i clone the sub and use one for my main thread and one for the websocket?
Or working with classes? Or is there a way to run the websocket class in the main thread like the normal web handler?
 
Last edited:
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
the last problem has nothing to do with the lib for now, the main question ist how to make resumable subs threadsafe.
Because calling from a websocket is a differnet thread and this also ends sometimes in the same error. I dont know how to access a resumable sub from a websocketclass to run in the main thread,

From MainThread: Thread[main,5,main]
From Websocket: Thread[pool-2-thread-1,5,main]
 
Upvote 0
Top