I have an app with many users. Periodically we review crashes with he customer.
There is one which has only appeared a couple of times, but I find it strange and can't understand why.
Perhaps it is quite obvious and someone can see what can go wrong here
From Crashlytics in Firebase Console:
It happens using bitmapCreator's getARGB() in an utility function used to 'custom tint' several monochrome bitmaps with transparent background from assets.
This Sub is called several times in the code and works with no issues for me (and for most users, otherwise I guess we'd have plenty of crashes)
There is one which has only appeared a couple of times, but I find it strange and can't understand why.
Perhaps it is quite obvious and someone can see what can go wrong here
From Crashlytics in Firebase Console:
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000003
b4i_bitmapcreator.m - Línea 4720
-[b4i_bitmapcreator _getargb:::] + 4720
...
It happens using bitmapCreator's getARGB() in an utility function used to 'custom tint' several monochrome bitmaps with transparent background from assets.
This Sub is called several times in the code and works with no issues for me (and for most users, otherwise I guess we'd have plenty of crashes)
B4X:
Sub LoadBitmapWithColorAndAlphaFactor(fileName As String, myColor As Int, alphaFactor As Float) As Bitmap
Dim fc As B4XBitmap = LoadBitmap(File.DirAssets,fileName)
Dim bmpc As BitmapCreator
bmpc.Initialize(fc.Width, fc.Height)
bmpc.CopyPixelsFromBitmap(fc)
Dim myARGB As ARGBColor
myARGB.Initialize
myARGB.r = Bit.And(0xFF, Bit.ShiftRight(myColor, 16))
myARGB.g = Bit.And(0xFF, Bit.ShiftRight(myColor, 8))
myARGB.b = Bit.And(0xFF, myColor)
Dim ARGB_final As ARGBColor
ARGB_final.Initialize
Dim c,r As Int
For c=0 To fc.Width-1
For r=0 To fc.Height-1
Dim ARGB As ARGBColor
bmpc.GetARGB(c,r,ARGB) ' <-- here is where the crash happens
If ARGB.a<>0 Then
ARGB_final.a = ARGB.a * alphaFactor
ARGB_final.r = myARGB.r
ARGB_final.g = myARGB.g
ARGB_final.b = myARGB.b
bmpc.SetARGB(c,r,ARGB_final)
End If
Next
Next
Return bmpc.Bitmap
End Sub