B4A crashing in debug so cant find problem

harlechguy

Member
Licensed User
Longtime User
Hi All, I have a project that keeps crashing in debug without any meaningful error message either in the B4A software or the actual application

The application has 3 main parts
1) start up and check if internal database is most recent version - if not download (FTP) newer version
2) download a series of manuals (jpegs). FTP as zip, then unpack.
3) populate a series of labels that are used for navigation
4) populate a panel with pictures (jpegs) based on label click choice

the program fails at the last part

I have attached a copy of the program (zip).

Any ideas much appreciated - many thanks
 

Attachments

  • DocBrowser.zip
    3.7 KB · Views: 184

stevel05

Expert
Licensed User
Longtime User
Have you checked the unfiltered logs? Depending on how many images you are loading you may find an out of memory error.
 
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Could not see anything in the unfiltered logs. The script fails when loading one picture.

Will keep looking and maybe strip back the code

Thanks
 
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Thanks Erel, unfiltered log is quite large and I have not spotted - will run again and have another look - must be missing something as it is a 'force close'
 
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Hi, have made a little progress over the last week but am still experiencing forced closes

Have narrowed it down a little to the following two subs and the error codes below.

the scenario is the app reads an sql database and based in the choice user makes loads a series of thumbnails.

the user clicks on a thumbnail and it scales to full size within a scroll panel

the error occurs when the user clicks the full size image - at this point the panel is cleared and the series of thumbnails is reloaded - currently am testing with one thumnail expanding to one full size image and then going back to one thumnail - it is at this point the program fails

the error codes appear to indicate that there is a problem with the way I am handling the loading and reloading of both the image and the thumbnail - am I on the right lines - Many thanks






SUBS:

Sub addthumbs(datab, dataa)
Dim cursor1 As Cursor

databholder = datab
dataaholder = dataa
Log(datab & " " & dataa)

Dim foldera As String
Dim c As Int

Dim T As Int
Dim L As Int

T = 15
L = 15

cursor1 = sql1.ExecQuery2("select Manual, Section, Page from Items where Manual = ? and Section = ?", Array As String(datab, dataa))
c = cursor1.RowCount
Dim thumb(c) As ImageView
If cursor1.RowCount=0 Then
Log("no manuals selected")
cursor1.Close
End If

If cursor1.RowCount > 0 Then
For i = 0 To cursor1.RowCount -1
thumb(i).Initialize("thumbclick")
cursor1.Position=i
manuala = cursor1.GetString("Manual")
manuala = manuala.Replace(" ","_")
sectiona = cursor1.GetString("Section")
sectiona = sectiona.Replace(" ","_")
page = cursor1.GetString("Page")
page=page.Replace(" ","_")
foldera = manuala & "/" & sectiona & "/" & page & ".jpeg"
Log(foldera)

'Panel2.AddView(thumb(i),L,5,675,1000)
Panel2.AddView(thumb(i),L,T,135,200)
Log(File.DirRootExternal&"/docbrowser/"&foldera)
thumb(i).Bitmap = LoadBitmap(File.DirRootExternal & "/docbrowser", foldera)
thumb(i).Gravity = Gravity.FILL
If L > 600 Then
L = 5
T = T + 210
Else
L = L + 145
End If
Next
cursor1.close
End If


End Sub

Sub thumbclick_click
Dim tc As ImageView
Dim sv As ScrollView
Dim pn As Panel
clearpanel2

If thumbflag = 0 Then
addthumbs(databholder,dataaholder)
thumbflag = 1
Return
End If

If thumbflag = 1 Then
sv.Initialize(1115)
pn = sv.Panel
sv.BringToFront
pn.BringToFront
tc = Sender
Panel2.AddView(sv,0,0,750,470)
pn.AddView(tc,5,5,750,1110)
thumbflag = 0
End If


End Sub


ERROR CODES:

threadid=1: stack overflow on call to Ljava/lang/reflect/Field;.<init>:VLLLI
method requires 24+20+4=48 bytes, fp is 0x42089318 (24 left)
expanding stack end (0x42089300 to 0x42089000)
Shrank stack (to 0x42089300, curFrame is 0x4208ba50)
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x4001d840)
GC_FOR_MALLOC freed 3457 objects / 342056 bytes in 22ms
FATAL EXCEPTION: main
java.lang.StackOverflowError
at java.lang.reflect.Field.<init>(Field.java:85)
at java.lang.reflect.ReflectionAccessImpl.clone(ReflectionAccessImpl.java:42)
at java.lang.ClassCache.deepCopy(ClassCache.java:530)
at java.lang.Class.getDeclaredFields(Class.java:710)
at anywheresoftware.b4a.BA.TypeToString(BA.java:423)
at harlech.docbrowser.main$_node.toString(main.java:215)


FATAL EXCEPTION: main
java.lang.StackOverflowError

java.lang.OutOfMemoryError: bitmap size exceeds VM budget
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Have a look at this post, it may help. The link is to the possible solution, but there is more info in the whole thread.
 
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Erel, Steve, thank you for your directions

I have followed the loadbitmapsample route as does not need additional libraries and is a little easier for me to follow

So far this has worked a treat - so thank you very much

For my learning - what are the limits with regards bitmaps?

the bitmap I am usings is 750kb. the loadbitmap sample does show a small amount of quality degradation when I scale the image.

thanks again - help, guidance very appreciated
 
Upvote 0
Top