Android app getting slower by use

Just starting out? Need help? Post your questions and find answers here.
hoerbie
Posts: 71
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Android app getting slower by use

Post by hoerbie »

@Fred: Thanks for the idea with the simple test code, and you are right, when used on Windows in Firefox it doesn't become slow, although I played with a lot higher number of up to 20000 opened and closed windows in the for loop.
I've modified your code to my programming style with BindEvent() instead of BindGadgetEvent(), it also has no performance problems on Firefox/Windows and Safari/macOS.
But using the memory analyses of Firefox I've found a map in spider.event that grows, please have a look at the debug output:

Code: Select all

Global log.s

Procedure Events()
  Debug EventGadget()
EndProcedure

For k = 0 To 1000
  Win = OpenWindow(#PB_Any, 0, 0, 200, 200, "Test")
  But = ButtonGadget(#PB_Any, 0, 0, 100, 30, "Hello")
  But2 = ButtonGadget(#PB_Any, 0, 40, 100, 30, "Hello")
  But3 = ButtonGadget(#PB_Any, 0, 80, 100, 30, "Hello")
  BindEvent(#PB_Event_Gadget, @Events(), Win, #PB_All, #PB_All)
  UnbindEvent(#PB_Event_Gadget, @Events(), Win, #PB_All, #PB_All)
  CloseWindow(Win)
Next

Win = OpenWindow(#PB_Any, 0, 0, 200, 200, "Test")
But = ButtonGadget(#PB_Any, 0, 0, 100, 30, "Hello")
But2 = ButtonGadget(#PB_Any, 0, 40, 100, 30, "Hello")
But3 = ButtonGadget(#PB_Any, 0, 80, 100, 30, "Hello")

BindEvent(#PB_Event_Gadget, @Events(), Win, #PB_All, #PB_All)

!v_log = JSON.stringify(spider.event, null, 4);
Debug log

Code: Select all

{
    "map": {
        "4_100000_-1_-1": {},
        "7_100000_-1_-1": {},
        "1_100001_-1_-1": {},
        "1_100002_-1_-1": {},
        "1_100003_-1_-1": {},
        "1_100004_-1_-1": {},
        "1_100005_-1_-1": {},
        "1_100006_-1_-1": {},
        "1_100007_-1_-1": {},
        "1_100008_-1_-1": {},
        "1_100009_-1_-1": {},
        "1_100010_-1_-1": {},
        "1_100011_-1_-1": {},
        "1_100012_-1_-1": {},
        "1_100013_-1_-1": {},
        "1_100014_-1_-1": {},
        "1_100015_-1_-1": {},
        "1_100016_-1_-1": {},
.....
        "1_100988_-1_-1": {},
        "1_100989_-1_-1": {},
        "1_100990_-1_-1": {},
        "1_100991_-1_-1": {},
        "1_100992_-1_-1": {},
        "1_100993_-1_-1": {},
        "1_100994_-1_-1": {},
        "1_100995_-1_-1": {},
        "1_100996_-1_-1": {},
        "1_100997_-1_-1": {},
        "1_100998_-1_-1": {},
        "1_100999_-1_-1": {},
        "1_101000_-1_-1": {},
        "1_101001_-1_-1": {},
        "1_101002_-1_-1": {}
    },
    "eventWindow": 0,
    "eventObject": 0,
    "eventType": 0,
    "eventData": 0
}
I don't know if it has to be this way, that the object keys stay there. I additionally tried calling UnbindEvent() for each closed window, but doesn't change anything.
Unfortunately I don't have an Android device at home now to test your code, but I will try it on a Sunmi M2 device on Monday at the office.
hoerbie
Posts: 71
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Android app getting slower by use

Post by hoerbie »

Tested this a lot now with 2.32 Beta 1 on my Android Sunmi M2 and a new testing script that doesn't open and close immediately but gives a more natural opening and closing.

Code: Select all

Global SWin, SBut1, SBut2, SBut3, STxt
Global TWin, TBut1, TBut2, TBut3
Global testopened

Procedure TEvents()
  Debug EventGadget()
EndProcedure

Procedure TestCloseWindow()
  If testopened > 0
    ;UnbindEvent(#PB_Event_Gadget, @TEvents(), TWin, #PB_All, #PB_All)
    CloseWindow(TWin)
    ! setTimeout(f_testopenwindow, 50);
  EndIf
EndProcedure

Procedure TestOpenWindow()
  TWin = OpenWindow(#PB_Any, 0, 200, 200, 200, "Test")
  TBut1 = ButtonGadget(#PB_Any, 0, 0, 100, 30, "Hello")
  TBut2 = ButtonGadget(#PB_Any, 0, 40, 100, 30, "Hello")
  TBut3 = ButtonGadget(#PB_Any, 0, 80, 100, 30, "Hello")
  BindEvent(#PB_Event_Gadget, @TEvents(), TWin, #PB_All, #PB_All)
  SetGadgetText(STxt, Str(TWin))
  ! setTimeout(f_testclosewindow, 200);
EndProcedure

Procedure SEvents()
  evgd = EventGadget()
  Debug Str(evgd)
  If evgd = SBut1
    testopened = 1
    TestOpenWindow()
  ElseIf evgd = Sbut2
    testopened = -1
  EndIf
EndProcedure

SWin = OpenWindow(#PB_Any, 0, 0, 200, 200, "Master")
SBut1 = ButtonGadget(#PB_Any, 0, 0, 100, 30, "Start")
SBut2 = ButtonGadget(#PB_Any, 0, 40, 100, 30, "Stop")
SBut3 = ButtonGadget(#PB_Any, 0, 80, 100, 30, "Hello")
STxt = StringGadget(#PB_Any, 0, 120, 100, 30, "")
BindEvent(#PB_Event_Gadget, @SEvents(), SWin, #PB_All, #PB_All)
I couldn't get it slowed down with my above script after more than thousand windows.

So there must be anything else as problem, in some of my windows there is a lot used of ListIconGadget() or CanvasGadget(), I will try additional tests with the new 2.40 Beta 2.
Post Reply