Hello All, i have been using this Threading library in a project i have been working on for a while, i just noticed something very strange, and i would like to know if anyone else has came across this issue or has anyone else even noticed it.
Here is the scenario, the app i'm working basically allows the user to select multiple images from their image gallery/camera etc... once the user selects all the images he/she intends to use then those images are stitched up together to make a video.
I'm using the threading library to display a circle progress library i created to show the current progress of the image/video processing. I know for a fact that it is not my circle progress bar library causing the issue as i have tried it in other projects and it works just fine.
The problem i'm seeing is that if I compile the app in Release (obfuscated mode) i receive this error after i select the images and the circle progress bar should appear and start showing the progress.
LogCat connected to: LGLS99055703165
--------- beginning of system
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
thumbtag :/storage/emulated/0/DCIM/Camera
** Activity (main) Pause, UserClosed = false **
** Activity (multipleselect) Create, isFirst = true **
** Activity (multipleselect) Resume **
** Activity (multipleselect) Pause, UserClosed = false **
** Activity (multipleselect) Resume **
item selected: /storage/emulated/0/DCIM/Camera/20150627_221602_HDR.jpg Items Selected: 1
item selected: /storage/emulated/0/DCIM/Camera/20150627_221503_HDR.jpg Items Selected: 2
item selected: /storage/emulated/0/DCIM/Camera/20150625_145959.jpg Items Selected: 3
item selected: /storage/emulated/0/DCIM/Camera/20150625_145947.jpg Items Selected: 4
item selected: /storage/emulated/0/DCIM/Camera/20150627_232122_HDR.jpg Items Selected: 5
item selected: /storage/emulated/0/DCIM/Camera/20150629_214241_HDR.jpg Items Selected: 6
item selected: /storage/emulated/0/DCIM/Camera/20150702_113902_HDR.jpg Items Selected: 7
item selected: /storage/emulated/0/DCIM/Camera/20150703_110238_HDR.jpg Items Selected: 8
item selected: /storage/emulated/0/DCIM/Camera/20150703_110247_HDR.jpg Items Selected: 9
item selected: /storage/emulated/0/DCIM/Camera/20150703_110254_HDR.jpg Items Selected: 10
item selected: /storage/emulated/0/DCIM/Camera/20150703_113027.jpg Items Selected: 11
item selected: /storage/emulated/0/DCIM/Camera/20150703_123614_HDR.jpg Items Selected: 12
** Activity (multipleselect) Pause, UserClosed = true **
onActivityResult: IOnActivityResult was released
** Activity (main) Resume **
number of images selected is: 12
** Service (processvideo) Create **
** Service (processvideo) Start **
processvideo_service_start (java line: 137)
java.lang.RuntimeException: Thread.Start : Sub threadsub1 not found!
at anywheresoftware.b4a.agraham.threading.Threading.Start(Threading.java:207)
at com.genesis.videomaker.processvideo._service_start(processvideo.java:137)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at com.genesis.videomaker.processvideo.handleStart(processvideo.java:71)
at com.genesis.videomaker.processvideo.onStartCommand(processvideo.java:55)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2887)
at android.app.ActivityThread.access$2100(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
java.lang.RuntimeException: Unable to start service com.genesis.videomaker.processvideo@118a522e with Intent { cmp=com.genesis.videomaker/.processvideo }: java.lang.RuntimeException: java.lang.RuntimeException: Thread.Start : Sub threadsub1 not found!
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2904)
at android.app.ActivityThread.access$2100(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Thread.Start : Sub threadsub1 not found!
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at com.genesis.videomaker.processvideo.handleStart(processvideo.java:71)
at com.genesis.videomaker.processvideo.onStartCommand(processvideo.java:55)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2887)
... 9 more
Caused by: java.lang.RuntimeException: Thread.Start : Sub threadsub1 not found!
at anywheresoftware.b4a.agraham.threading.Threading.Start(Threading.java:207)
at com.genesis.videomaker.processvideo._service_start(processvideo.java:137)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
... 13 more
--------- beginning of crash
Now if i compile the project in just Release mode (not obfuscated) then everything runs just fine.
Is this an issue with the threading library or with B4A itself, i'm using the latest and greatest version of B4A version 5.02 (1).
Has anyone else experienced this? I know it is not a big deal since i can still run the project in Release mode, but i would like to obfuscate the code so that it makes it harder for anyone else to de-compiles and sees my code once i release my app.
here is the relevant code in my ProcessVideo service
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private video As VideoMaker
Private thread1 As Thread
Dim lock1 As Lock
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim args(0) As Object
thread1.Initialise("thread1")
lock1.Initialize(True)
thread1.Name = "Thread 1"
thread1.Start(Null, "ThreadSub1", args)
End Sub
Sub Service_Destroy
End Sub
Sub ThreadSub1
DoEvents
video.Initialize("video", Main.thumbtag, Main.newl, 480, 800 )
'DoEvents
Dim count As Int
Dim params(1) As Object
Do While count < Main.newl.Size
count = count + 1
params(0) = count
ok = False
Do Until ok
thread1.RunOnGuiThread("Update1", params)
ok = lock1.WaitFor(10)
Loop
Loop
MultipleSelect.selectedpics.Clear
Main.newl.Clear
Log("finished processing video")
End Sub
Sub Update1(count As Int)
Log("Image number: " & count)
lock1.Unlock
End Sub
Sub Thread1_Ended(endedOK As Boolean, error As String) 'The thread has terminated. If endedOK is False error holds the reason for failure
Log("thread ended: " & endedOK & " " & "Error: " & error)
StopService("")
End Sub
Sub video_progress(progress As Int)
Dim prog As Float
'Log("list size: " & MultipleSelect.selectedpics.Size)
prog = (100/(MultipleSelect.selectedpics.Size))
Dim prg As Double
prg = prog
CallSubDelayed2(Main, "Update_Progress", prg)
End Sub
attached is a screenshot of when the app runs fine if compiled in regular release mode.
Hope either the Author of this library or Erel can answer this post.
Thanks,
Walter