iOS Question Help!! Store version behaving differently to debug version

Arf

Well-Known Member
Licensed User
Longtime User
Hi,
I've just got my app out on the App store, uninstalled my debug version and bought the app. It crashes out when I try add something to the database. This doesn't happen with the debug or release version when I was developing.

Don't know where to start debugging this now, any suggestions? I don't have a mac, only iphone SE.
 

Arf

Well-Known Member
Licensed User
Longtime User
I'm pretty sure I did, should I uninstall the store app now and install my release APK using b4i bridge and check again?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Uninstalled store version, compiled again with my development certificates and ran through B4i bridge - everything fine.
Now I can't remember how to get a non-debug version onto my device, I've built a release (with my debug certificate and downloaded it), how to get it on the iphone?
Sorry I'm really stressed, brain is seizing up
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
OK got it right, release version (with debug certs) crashes at the same point! Maybe I didn't uninstall debug version first when checking.
Still, where to go from here?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Ok, I commented out some code which access the database at the point the crash occurs, rebuild release app and installed to device - no crash.
It is one of the following lines that is crashing it:
B4X:
    PBactivity.pblist = DBUtils.ExecuteMemoryTable(SQL,"SELECT * FROM PersonalBests ORDER BY LiftName ASC",Null,0)
   
    Dim pp(2) As String

    For i=0 To PBactivity.pblist.Size - 1
        pp = PBactivity.pblist.Get(i)
       
        'now populate height/ethnicity if they are null
        If pp(0) = Null Then pp(0) = 0
        If pp(1) = Null Then pp(1) = 0
    Next
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Digging further, this line appears to be causing the crash:
B4X:
Dim rs As ResultSet = SQL.ExecQuery2(Query, StringArgs)

Is it because I have NULL for String arguments in the call to DBUtils? the function +args looks like this:
B4X:
Public Sub ExecuteMemoryTable(SQL As SQL, Query As String, StringArgs() As String, Limit As Int) As List
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I have re-used DBUtils from a B4A app, perhaps the SQL implementation is slightly different - but then I would have expected issues in debug mode.
what I'll looking at currently is the arguments for DBUtils.ExecuteMemoryTable and the call inside that function to SQL.ExecQuery2. I can see that SQL.ExecQuery2 takes stringargs as a LIST, while DBUtils is receiving it as STRING array, and I'm sending a NULL when calling DBUtils.
Does that sound like it could be the root of the problem?
 

Attachments

  • function.jpg
    function.jpg
    140.7 KB · Views: 142
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Ok thanks, didn't see your previous message till after I posted my last. Trying iReleaseLogger now. Thanks for your help!
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Ok, this is what I get out of the logger when trying to add something to the DDB, this is when the app first crashes:
ExecuteMemoryTable: SELECT * FROM PersonalBests WHERE (LiftName='Back Squat') OR
DER BY LiftName ASC
InsertMaps (first query out of 1): INSERT INTO [PersonalBests] ([Weight], [LiftN
ame]) VALUES (?, ?)
ExecuteMemoryTable: SELECT * FROM PersonalBests ORDER BY LiftName ASC
Cannot parse: Back Squat
Stack Trace: (
CoreFoundation <redacted> + 148
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
Crossfit Toolbox -[B4I ObjectToNumber:] + 472
Crossfit Toolbox -[b4i_pbactivity _loadtablefrompatients] + 2320
Crossfit Toolbox -[b4i_pbactivity _btndone_click] + 2584
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 284
Crossfit Toolbox +[B4I runDynamicMethod:method:throwErrorIfMissing:args:]
+ 1872
Crossfit Toolbox -[B4I raiseEvent:event:params:] + 480
Crossfit Toolbox __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib _dispatch_main_queue_callback_4CF + 1000
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 1660
CoreFoundation CFRunLoopRunSpecific + 444
GraphicsServices GSEventRunModal + 180
UIKit <redacted> + 684
UIKit UIApplicationMain + 208
Crossfit Toolbox main + 124
libdyld.dylib <redacted> + 4

Problem is 'Cannot Parse 'Back Squat'...
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
and on subsequent starts of the app, it crasges when it tries to read data from the database, log below:
Waiting on port 54323
ExecuteMemoryTable: SELECT * FROM PersonalBests ORDER BY LiftName ASC
Cannot parse: Back Squat
Stack Trace: (
CoreFoundation <redacted> + 148
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
Crossfit Toolbox -[B4I ObjectToNumber:] + 472
Crossfit Toolbox -[b4i_pbactivity _loadtablefrompatients] + 2320
Crossfit Toolbox -[b4i_pbactivity _show] + 4464
Crossfit Toolbox -[b4i_main _personalbestbutton_click] + 60
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 284
Crossfit Toolbox +[B4I runDynamicMethod:method:throwErrorIfMissing:args:]
+ 1872
Crossfit Toolbox -[B4I raiseEvent:event:params:] + 480
Crossfit Toolbox __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib _dispatch_main_queue_callback_4CF + 1000
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 1660
CoreFoundation CFRunLoopRunSpecific + 444
GraphicsServices GSEventRunModal + 180
UIKit <redacted> + 684
UIKit UIApplicationMain + 208
Crossfit Toolbox main + 124
libdyld.dylib <redacted> + 4

so actually both look the same, so the write to DDB seems fine, it's when the ddb is queried to retrieve what's in there. Look's like somehow it's trying to cast the lift_type string as a number
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Nope, the read from database is OK, it's a cast problem in my code, probably in loadtablefrompatients.
Is there any way I can find a line number for my code from the log info?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Ok, narrowed it down more. crash occurs on this line:

B4X:
List1.Add(Array As String(pp(0),roundit(pp(1)),roundit(pp(1)*0.95),roundit(pp(1)*0.9),roundit(pp(1)*0.85),roundit(pp(1)*0.8),roundit(pp(1)*0.75),roundit(pp(1)*0.7),roundit(pp(1)*0.65),roundit(pp(1)*0.6)))

The problem is, pp(0) always seemed to be lift_type (a string) when in debug, and pp(1) was always the weight (number).
In release mode, the two seem to have swapped places.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Ok, so I remember that one of the last things I did was to change the 'DESC' to 'ASC' in this call:
B4X:
PBactivity.pblist = DBUtils.ExecuteMemoryTable(SQL,"SELECT * FROM PersonalBests ORDER BY LiftName ASC",Null,0)

That seems to have changed the order of not only the actual PersonalBests retrieved, but also of the individual elements therein.
Is that expected?

For now I've put in a quick n dirty fix:
B4X:
'try this
        If IsNumber(pp(0)) = True Then        'must be swapped
            Dim store As String = pp(1)
            pp(1) = pp(0)
            pp(0) = store
        End If
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The explanation for this issue:
The problem is in DBUtils.CreateTable. It accepts a map with the fields and their types. Unlike B4A / B4J the order of map items is not preserved. Practically it breaks the usefulness of ExecuteMemoryTable as the column order is random.

I will update DBUtils to accept two lists instead of a map.

You didn't see this error because the database is only created when the app first runs.
 
Upvote 0
Top