Android Question why Panel.visible is OK in Debug mode, not in Release ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

Strange situation...
A panel with custom keyboard is created in runtime dynamically, variable for several situations - so, it's impossible just to load a layout.
When needed - a sub initializes the panel, adds onto Activity, prepares buttons... and makes Panel.visible = true. When typing is finished - panel is fully unloaded by
B4X:
pnlContainer.RemoveAllViews
pnlContainer.RemoveView
In the debug mode all is working OK.

But in the Release mode - panel is not shown. WHY ?
B4A9.8, Emulator.

p.s. such .... thing helped:
B4X:
pnlContainer.Initialize("pnl")
Log("1")
pnlContainer.Visible = False
Log("2")
Activity.AddView(pnlContainer, 0, 0, 100%x, 100%y)
Log("3")

BUT WHY ? :rolleyes:
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
B4X:
Sub Show_Selection
If pnlContainer.IsInitialized Then
    If pnlContainer.Visible Then
        Return
    End If
End If

others.AddToLog("Selecting linie")

pnlContainer.Initialize("pnl")
Log("1")  'this helps in Release mode, why ?
pnlContainer.Visible = False
Log("2")  'this helps in Release mode, why ?
Activity.AddView(pnlContainer, 0, 0, 100%x, 100%y)
Log("3")  'this helps in Release mode, why ?
pnlContainer.Color = Colors.ARGB(220, 30, 30, 30)
Dim lbl As Label
lbl.Initialize("")
lbl.Text = "Linie / Fahrtnummer eingeben"
lbl.TextColor = Colors.White
lbl.Gravity = Gravity.CENTER_HORIZONTAL


txt.Initialize("txt")
txt.SingleLine = True
#if ver8
    txt.InputType = txt.INPUT_TYPE_NONE    'INPUT_TYPE_TEXT
    IME.SetCustomFilter(txt, txt.INPUT_TYPE_NONE, "0123456789/")
    txt.Hint = "z.B. 7/68"
#else if ver7
    txt.InputType = txt.INPUT_TYPE_NUMBERS
    IME.SetCustomFilter(txt, txt.INPUT_TYPE_NONE, "0123456789")
    txt.Hint = "z.B. 768"
#end if


txt.Wrap = False
txt.Gravity = Gravity.TOP
txt.HintColor = 0xFF4A494A
txt.Color = 0xFF656365

    Dim pnlKeyboard As Panel
    pnlKeyboard.Initialize("")

    pnlContainer.AddView(lbl, 0, 5%y, 100%x, 9%y)
    pnlContainer.AddView(txt, 0, lbl.Top + lbl.Height + 5dip, 100%x, 17%y)
    pnlContainer.AddView(pnlKeyboard, 0, txt.Top + txt.Height * 2, 100%x, 64%y)
    pnlKeyboard.Height = 100%y - pnlKeyboard.Top
    pnlKeyboard.LoadLayout("kbd")
    
    Dim Padding As Int = 10dip
    Dim H As Int = (100%y - pnlKeyboard.Top - Padding * 5) / 4
    but1.Height = H
    but2.Height = H
    but3.Height = H
    but4.Height = H
    but5.Height = H
    but6.Height = H
    but7.Height = H
    but8.Height = H
    but9.Height = H
    but0.Height = H
    butDel.Height = H
    butSlash.Height = H
    butOK.Height = H
    
    but1.Width = H * 2.13
    but2.Width = but1.Width
    but3.Width = but1.Width
    but4.Width = but1.Width
    but5.Width = but1.Width
    but6.Width = but1.Width
    but7.Width = but1.Width
    but8.Width = but1.Width
    but9.Width = but1.Width
    but0.Width = but1.Width
    butDel.Width = but1.Width
    butOK.Width = but1.Width
    butSlash.Width = but1.Width
    
    but2.Left = but1.Left + but1.Width + Padding
    but3.Left = but2.Left + but2.Width + Padding
    but5.Left = but4.Left + but4.Width + Padding
    but6.Left = but5.Left + but5.Width + Padding
    but8.Left = but7.Left + but7.Width + Padding
    but9.Left = but8.Left + but8.Width + Padding
    but0.Left = butSlash.Left + butSlash.Width + Padding
    butDel.Left = but0.Left + but0.Width + Padding
    butOK.Left = butDel.Left + butDel.Width + Padding
    
    but4.Top = but1.Top + but1.Height + Padding
    but5.Top = but1.Top + but1.Height + Padding
    but6.Top = but1.Top + but1.Height + Padding
    but7.Top = but4.Top + but4.Height + Padding
    but8.Top = but4.Top + but4.Height + Padding
    but9.Top = but4.Top + but4.Height + Padding
    but0.Top = but7.Top + but7.Height + Padding
    butDel.Top = but7.Top + but7.Height + Padding
    butOK.Top = butDel.Top
    butSlash.Top = but7.Top + but7.Height + Padding
        
    but1.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-1.png"))
    but2.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-2.png"))
    but3.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-3.png"))
    but4.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-4.png"))
    but5.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-5.png"))
    but6.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-6.png"))
    but7.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-7.png"))
    but8.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-8.png"))
    but9.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-9.png"))
    but0.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste-0.png"))
    butDel.SetBackgroundImage(LoadBitmap(File.DirAssets, "del.png"))
    butSlash.SetBackgroundImage(LoadBitmap(File.DirAssets, "slash.png"))
    butOK.SetBackgroundImage(LoadBitmap(File.DirAssets, "Taste_OK.png"))

#if ver8
    butSlash.Visible = True
    pnlKeyboard.Width = butOK.Left + butOK.Width + 10dip
#else if ver7
    butOK.Left = but1.Left
    pnlKeyboard.Width = butDel.Left + butDel.Width + 10dip
    butSlash.Visible = False
#end if
    pnlKeyboard.Left = (100%x - pnlKeyboard.Width)/2

lbl.TextSize = 30
txt.TextSize =     48
pnlContainer.Visible = True
txt.RequestFocus
End Sub
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Try setting the size of the panels with SetLayout while they are invisible and before starting to make any operation with the panels.
For both pnlcontainer and pnlkeyboard
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Sometimes after compilation to Release mode - all is working OK, but mostly after any other re-compilation - is not shown in Release mode.
I cannot catch the difference...
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Anyway you wrote that you are testing with Emulator.
While I think that Emulators are a good resource they will never be as reliable as a real device.
In such cases a test on a real device can help you understand if there is a consistent problem or if it's just an Emulator flaw.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
real device

Yes, the customer of this app is testing on his real devices and confirms the same situation.
Hmmm, no - at customer devices it works OK !
Mystics...
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Also found that now in Release mode the events are not fired !
Like:

B4X:
Sub FTP1_DownloadCompleted (ServerPath As String, Success As Boolean)
Log("DownloadCompleted: " & ServerPath & ", Success=" & Success)

If ServerPath.EndsWith("client.txt") Then
    CallSubDelayed(Main, "client_txt_downloaded")    'event to sub where the file is being waited
    Return
End If
....
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
in a small project

Hmm, in a separate small project, if to move there only this sub, creating the keyboard - no any trouble to show and hide the panel in Release mode in this Emulator.
And without any extra LOG() pauses ...
And customer tested the APK (that at my Emulator does not show this panel) on his real devices - works OK (in Release mode) !

Now even in Debug mode the events are not fired. Only if to set the breakpoint before the event - it fired after F5.

It looks like some freezes or "speed race"...
But how to understand the reason?
 
Last edited:
Upvote 0

eps

Expert
Licensed User
Longtime User
Feels like a cache issue - is it still the case that - there used to be a manifest setting, but I can't remember it off the top of my head..
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
No, without BP - no events in Emulator API29.

Next info and results:
1) The app was and is compiled for API 19 by android-29\android.jar (customer's request)
2) In Emulator API 29 - such trouble (in Release mode events are not fired)
3) On real devices API 28 - the same trouble! But after 3-5 mins with switched off screen - works OK !
4) On real device API 24 - no any troubles, all works OK.
šŸ™€

Compilation for API29 - no help in Emulator API29.
 
Last edited:
Upvote 0
Top