What else (no coffee!)

LucaMs

Expert
Licensed User
Longtime User
In my app, an Activity restarts randomly (I don't want it, of course).

To find this bug I did ALL:

1) debug step by step;
2) log of messages received from my server
3) log unfiltered
4) debug using my AddLogs
5) modified AddLogs to log ALL LINES EXECUTED!!!

There are no pending calls (sometimes you can see that some messages are queued).

I'm writing here, Chit Chat, because I know that nobody could help me without the projects (B4A & B4J). So this is just to say...

AAAAAAARRRRRRRGGGGGGGHHHHH
 
Last edited:

JordiCP

Expert
Licensed User
Longtime User
When you say that an activity restarts randomly, do you mean...

a) the currently foreground Activity goes to Pause and then Resume?
b) an activity, which at that moment is paused comes into life? --> if so, the first Sub executed in that activity (after Activity_Resume) may be the clue. Perhaps it has been called through an intent, callSubDelayed, .... from a running service, as the code to be executed in a Callback when some event has happened.
 

LucaMs

Expert
Licensed User
Longtime User
Last edited:

LucaMs

Expert
Licensed User
Longtime User
When you say that an activity restarts randomly, do you mean...

a) the currently foreground Activity goes to Pause and then Resume?
b) an activity, which at that moment is paused comes into life? --> if so, the first Sub executed in that activity (after Activity_Resume) may be the clue. Perhaps it has been called through an intent, callSubDelayed, .... from a running service, as the code to be executed in a Callback when some event has happened.

It's the same Activity I close, using Activity.Finish.

As I wrote:
5) modified AddLogs to log ALL LINES EXECUTED!!!
and after Activity.Finish no other line of my code is executed, so something that is hidden starts the Activity.
The only thing I can think to is an Android message delivered with delay but there is no logs about this, not even with the unfiltered log.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Unfiltered log.
I replaced the package name to xxx.xxxxx.xxx, for "privacy"


EnableSpeaker (enable 1)
setSpeaker::mode=0,prestate=0,state=1
Chiudo actGameRoom <--- I closed the activity here
EnableHeadPhone(enable=0)
setHeadphone::mode=0,prestate=0,state=0
Audio_Find_Normal_Output_Device mRoutes=0x2
AudioStartRunning mCurrentDevice = 0x2
!!! Afe_DL_Start OpenMode=0
Afe_DL_Start AFE_MODE_DAC SR_index = 7 SR_index_mode = 9
Afe_DL_Start, +AFE_DL_SRC2_1 (0x73000602)
Afe_DL_Start, -AFE_DL_SRC2_1 (0x73000603)
[CDS]EAGAIN or EWOULDBLOCK in Recvfrom
-AudioStartRunning
GC_FOR_ALLOC freed 852K, 13% free 15673K/17927K, paused 119ms
handleMessage: E msg.what=131155
processMsg: ConnectedState
ConnectedState{ what=131155 when=-46ms arg1=2 }
[wlan0] Issue cmd = 'SIGNAL_POLL'
CMD = SIGNAL_POLL
wpa_driver_signal_poll
fetchRssiAndLinkSpeedNative, newRssi=-63
handleMessage: X
acquireWakeLock flags=0x1 tag=ActivityManager-Launch
[DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x1f95510
No new IME target
Focus gain on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41ced6c0 (uid=10081 pid=1835)
stop(4099), calling thread 252
(> STOPPED) => STOPPED (4099) on thread 0x7c3d88
stopOutput() tid 104
stopOutput() output 1, stream 1, session 20
setOutputDevice() output 1 prevDevice 2 device 0 force = 0
setOutputDevice() setting same device 0 or null device for output 1
audiotrack 0x1a8c738 stop done
** Activity (actgameroom) Pause, UserClosed = true **
ACT-AM_ON_PAUSE_CALLED ActivityRecord{41a740d0 token=android.os.BinderProxy@4197db88 {xxx.xxxxx.xxx/xxx.xxxxx.xxx.actgameroom}}
setKeyboardVisibility: false
ACT-Launching: ActivityRecord{41e07a08 xxx.xxxxx.xxx/.actgameroom}
threadid=77: interp stack at 0x4d0ce000
ACT-PAUSE_ACTIVITY_FINISHING handled : 0 / android.os.BinderProxy@4197db88
ACT-AM_ON_RESUME_CALLED ActivityRecord{41988978 token=android.os.BinderProxy@41988248 {xxx.xxxxx.xxx/xxx.xxxxx.xxx.actgameroom}}
ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{41988978 token=android.os.BinderProxy@41988248 {xxx.xxxxx.xxx/xxx.xxxxx.xxx.actgameroom}}
Changing focus from Window{41c561d0 xxx.xxxxx.xxx/xxx.xxxxx.xxx.actgameroom paused=true} to Window{41ccce98 xxx.xxxxx.xxx/xxx.xxxxx.xxx.actgameroom paused=false}
Gaining focus: Window{41ccce98 xxx.xxxxx.xxx/xxx.xxxxx.xxx.actgameroom paused=false}
[xxx.xxxxx.xxx/xxx.xxxxx.xxx.actgameroom(0x16ab568)] connect: api=1
threadid=77: calling run()
threadid=77: exiting
threadid=77: bye!
threadid=0: freeing
** Activity (actgameroom) Create, isFirst = false **
TrackBase::reset
[CDS]EAGAIN or EWOULDBLOCK in Recvfrom
write mute data to mixerBuffer
GC_FOR_ALLOC freed 1427K, 13% free 15171K/17415K, paused 38ms
Grow heap (frag case) to 16.334MB for 1536016-byte allocation
write mute data to mixerBuffer
GC_FOR_ALLOC freed 30K, 13% free 16640K/18951K, paused 43ms
write mute data to mixerBuffer
[CDS]EAGAIN or EWOULDBLOCK in Recvfrom
write mute data to mixerBuffer
GC_FOR_ALLOC freed 106K, 9% free 17666K/19207K, paused 31ms
** Activity (actgameroom) Resume **
write mute data to mixerBuffer
[AppLaunch] Displayed xxx.xxxxx.xxx/.actgameroom: +406ms
AP_PROF:AppLaunch_LaunchTime:xxx.xxxxx.xxx/.actgameroom:406:232615
send cmd: check
builder success
 

LucaMs

Expert
Licensed User
Longtime User
Log from a modified version of AddLogs (writes all lines that will be executed. In brackets the name of the module, when a routine starts).

[actGameRoom] the Activity "automatically" restarted
[clsPlayer] a Class
[cvPlayer] a custom View
[srvComm] a Service
[WSHandler] a websocket handler class


[actGameRoom] code...Private Sub btnExit_Click
code...Dim Answ As Int
code...Dim txt As String
code...txt = "Exit from room: are you sure?"
code...If mStatus = STATUS_PLAYING Then
code...txt = txt & CRLF & CRLF & "IF YOU EXIT NOW, YOU WILL PAY xxx"
code...End If
code...Answ = Msgbox2(txt, "ATTENTION", "Yes", "", "No", Null)
code...If Answ = DialogResponse.POSITIVE Then
code...RemovePlayer(mMyTurnOrder)
[actGameRoom] code...Private Sub RemovePlayer(TurnOrder As Int)
code...Dim Player As clsPlayer = mmapPlayers.Get(TurnOrder)
code...mPlaces(Player.PlaceIndex).GetLabelTop.Text = "Vacancy"
[clsPlayer] code...Public Sub getPlaceIndex As Int
code...Return mPlaceIndex
[cvPlayer] code...Public Sub GetLabelTop As Label
code...Return mlblTop
code...mPlaces(Player.PlaceIndex).Photo = mDefaultPhoto
[clsPlayer] code...Public Sub getPlaceIndex As Int
code...Return mPlaceIndex
[cvPlayer] code...Public Sub setPhoto(Photo As Bitmap)
code...mPhoto = Photo
code...mivPhoto.Color = mPhotoColor
code...FitCenterBitmap(mivPhoto, Photo)
[cvPlayer] code...Private Sub FitCenterBitmap(Imv As ImageView, bmp As Bitmap)
code...Private cvs As Canvas
code...cvs.Initialize(Imv)
code...Dim rectDest As Rect
code...Dim delta As Int
code...If bmp.Width / bmp.Height > Imv.Width / Imv.Height Then
code...delta = (Imv.Width - bmp.Width / bmp.Height * Imv.Height) / 2
code...rectDest.Initialize(delta, 0, Imv.Width - delta, Imv.Height)
code...End If
code...SetAntiAlias(cvs, FILTER_BITMAP_FLAG) ' non cambia alcunchƩ, in questo caso!
[cvPlayer] code...Private Sub SetAntiAlias (c As Canvas, FilterFlag As Int)
code...Dim r As Reflector
code...Dim NativeCanvas As Object
code...r.Target = c
code...NativeCanvas = r.GetField("canvas")
code...Dim PaintFlagsDrawFilter As Object
code...PaintFlagsDrawFilter = r.CreateObject2("android.graphics.PaintFlagsDrawFilter",Array As Object(0, FilterFlag), Array As String("java.lang.int", "java.lang.int"))
code...r.Target = NativeCanvas
code...r.RunMethod4("setDrawFilter", Array As Object(PaintFlagsDrawFilter), Array As String("android.graphics.DrawFilter"))
code...cvs.DrawBitmap(bmp, Null, rectDest)
code...Imv.Gravity = Gravity.FILL
code...Imv.Invalidate
code...Player = Null
code...mMyTurnOrder = -1
code...CallSubDelayed2(srvComm, "RunOnServerPlayerExitsGameRoom", True)
code...LogColor("Chiudo actGameRoom", Colors.Red)
Chiudo actGameRoom <---
code...Activity.Finish
code...End If
[srvComm] code...Private Sub RunOnServerPlayerExitsGameRoom(Voluntary As Boolean)
code...Dim Data As Map : Data.Initialize
code...Data.Put("Voluntary", Voluntary)
code...wsh.SendEventToServer("PlayerExitsGameRoom", Data)
[WSHandler] code...Public Sub SendEventToServer(Event As String, Data As Map)
code...Dim m As Map
code...m.Initialize
code...m.Put("type", "event")
code...m.Put("event", "FromClient_" & Event)
code...m.Put("params", Data)
code...Dim jg As JSONGenerator
code...jg.Initialize(m)
code...ws.SendText(jg.ToString)
** Activity (actgameroom) Pause, UserClosed = true **
[actGameRoom] code...Sub Activity_Pause (UserClosed As Boolean)
code...ActivityIsStarted = Not(UserClosed)
** Activity (actgameroom) Create, isFirst = false **
[actGameRoom] code...Sub Activity_Create(FirstTime As Boolean)
code...Activity.LoadLayout("layGameRoom")


As you can see (not so easily :)) no messages from server are arrived.
 
Last edited:

ilan

Expert
Licensed User
Longtime User
why are you posting an issue/question in the chit chat forum?
if this thread may be useful for someone else the search bar wont find it since it does not include results from the chit chat forum.

your post #15 is very unclear since you dont use the code view when you post a code.

(you should know that after 10k posts o_O)


can you upload a small project where the issue can be reproduced?
 
Top