Android Question ... Isn't Responding. Do you want to close it?

TheWind777

Active Member
Licensed User
Longtime User
I am so frustrated.

My program keeps doing that.

Even when I turn off all the timers it does it.

I have put DoEvents in every subroutine.

I have put a:

B4X:
EventCounter = 0

Do While Not(Done)
   ' (code that does stuff until stuff is done, then Done = True)

   If EventCounter Mod 3 = 0 Then
      If Debug Then Log("DoEvents")
      DoEvents
   EndIf

   EventCounter = EventCounter + 1
Loop

Inside every 'Do Until' and 'Do While' statement

If I ever have an else that might end up empty if the Debug flag is turned-off I put a DoEvents:

B4X:
If something= something then
  ' Do a bunch of stuff
else
  If Debug then Log("such-and-such")
  DoEvents
end if

In every timing event I have put DoEvents in every If / then / else section

I did it via copy/paste and then verified that all 350 subroutines had a DoEvents.

All of the Service module's Subroutines all have almost too many DoEvents scattered throughout (in every loop, in every if/then/else..., before exiting every Sub).

I have copious settings flags which turn-off almost everything (meaning disabling most every timer that might be running in the background) and even when I turn them off, it occurs.

I figure that, somewhere, maybe some infinite loop must be occurring?

What am I missing? Is there a way to see what subroutine or timer the operating system is thinking is locked-up?

How do I debug this problem and determine what is causing it? I've been plagued by it for about a week (been working on the program now since January, and it's proprietary code; so can't post it).
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Use the controls at the top of the debug window, press the play button to continue, the second button to step to the next line or the stop button to exit the session.

upload_2014-7-18_16-0-36.png
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
Change the option in the dropdown, then set a breakpoint on the line you want by clicking in the left hand gutter. You should see a red circle.


View attachment 26416


So, silly me, I told it to crash for me.

How I told it to crash was by turning-on the Strict Mode, apparently.

I guess I have to turn on a thing called penaltylog(), somehow? in order to have it give me more detail as to why it crashed?

Do you know what strictmode
android.os.StrictMode$StrictModeNetworkViolation: policy=31 violation=4 is?

Is there some page which lists the policy and violation numbers?

I'm not using the Network in my App, nor do I have any subroutine code having to do with the Network. It must mean something else.

Do you know how to turn on penaltyLog() with strictmode?

I think I turned on strictmode to tell me more information if the service module crashes... correct?

Obviously, if any errors are triggering, that means something is going wrong. I want to fix all errors, no matter what they are.

I suspect I may not be putting something in the Manifest that I need to put there.

Right now I have:

B4X:
'This code will be applied to the manifest file during compilation.

'You do not need to modify it in most cases.

'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136

AddManifestText(

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>

<supports-screens android:largeScreens="true"

android:normalScreens="true"

android:smallScreens="true"

android:anyDensity="true"/>)

AddPermission(android.permission.GET_TASKS)

AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)

AddPermission(android.permission.RECORD_AUDIO)

SetApplicationAttribute(android:icon, "@drawable/icon")

SetApplicationAttribute(android:label, "$LABEL$")

'End of default text.

Also, are there any Permissions I should also be adding, there?

I want them to be able to save stuff to an external SD card if they have one. It needs to record audio. I don't remember why I added GET_TASKS (Maybe it's built-in).
 
Last edited:
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
I get mad reading the complexity of your code. Are you sure you can not do otherwise?

View attachment 26403


Actually... my code is about the most readable code you'll ever see, I would say. I use long and intricate variable names which read like English. Reading my code is like reading the old COBAL code, which was designed so the bigwigs in corporation could understand what as going on. My code is the only code I know of where someone who doesn't know how to program at all might know what it's doing.

If I pick any random subroutine... I'd bet you could figure out exactly what it is doing without seeing any other subroutine.

Lets pick any random subroutine. I'd bet that without seeing any other subroutine, you can easily figure out what the code is doing:

B4X:
Sub Activity_KeyPress(KeyCode As Int) As Boolean 'Return True to consume the event

Dim Answ As Int

Dim Volume As Int

Dim Done As Boolean = False

Dim HELPPANEL_NeedsStackBackup As Boolean

Dim TUTORPANEL_NeedsStackBackup As Boolean


DoEntry("Activity_KeyPress()")



If KeyCode = KeyCodes.KEYCODE_VOLUME_UP AND Not(AUDIO_IncreaseBeingUsed) AND pnlLock.Visible = False Then

DEBUG1("Activity_KeyPress() - Increasing Volume")

Volume = LIB_Phone.GetVolume(1)

LIB_Phone.SetVolume(1,Volume+1,SHOW_VOLUME_CONTROL)

AUDIO_IncreaseBeingUsed = True


EnableTIMER(TIMERNUMBER_IncreaseVolume)

End If


If KeyCode = KeyCodes.KEYCODE_VOLUME_DOWN AND Not(AUDIO_DecreaseBeingUsed) AND pnlLock.Visible = False Then

DEBUG1("Activity_KeyPress() - Decreasing Volume")

Volume = LIB_Phone.GetVolume(1)

LIB_Phone.SetVolume(1,Volume-1,SHOW_VOLUME_CONTROL)

AUDIO_DecreaseBeingUsed = True


EnableTIMER(TIMERNUMBER_DecreaseVolume)

End If


If KeyCode = KeyCodes.KEYCODE_BACK Then


DisableTIMER(TIMERNUMBER_GIF)



SaveSettingsScrollPos("")

SaveHelpScrollPos("")

SaveTutorScrollPos("")

StopAllRecordAndPlay("")

CloseAllQuestions("")

CloseURL("")



DEBUG1("Activity_KeyPress() KEYCODE_BACK - STACK_Pointer = " & STACK_Pointer)



' If there are things on the Stack, back-up one

' Unless it is the HELPPANEL, then do a ScrollPos = 0 if ScrollPos isn't zero

' Otherwise do a regular back-up in the stack

If LastPanel = HELPPANEL OR LastPanel = TUTORPANEL Then

DEBUG1("Activity_KeyPress() KEYCODE_BACK - LastPanel = HELPPANEL")

If wvX.getScrollY(wvHelpOrTutor) <> 0 Then

' It wasn't at the top, so set it to the top and don't back-up one level in the stack


If LastPanel = HELPPANEL Then

HELPPANEL_NeedsStackBackup = False

DEBUG1("Activity_KeyPress() KEYCODE_BACK - wvHelpOrTutor.Top <> 0; HELPPANEL_NeedsStackBackup = False")

Else

TUTORPANEL_NeedsStackBackup = False

DEBUG1("Activity_KeyPress() KEYCODE_BACK - wvHelpOrTutor.Top <> 0; TUTORPANEL_NeedsStackBackup = False")

End If


wvE.PageUp(True)



DEBUG1("Activity_KeyPress() KEYCODE_BACK - Set wvHelpOrTutor.Top = 0")

DEBUG1("Activity_KeyPress() - DoEvents #1")

DoEvents

Else

' It was already at the top, so they just want to back up one stack level

If LastPanel = HELPPANEL Then

DEBUG1("Activity_KeyPress() KEYCODE_BACK - wvHelpOrTutor.Top = 0; HELPPANEL_NeedsStackBackup = True")

HELPPANEL_NeedsStackBackup = True

Else

DEBUG1("Activity_KeyPress() KEYCODE_BACK - wvHelpOrTutor.Top = 0; TUTORPANEL_NeedsStackBackup = True")

TUTORPANEL_NeedsStackBackup = True

End If

End If

End If


If (LastPanel <> HELPPANEL AND LastPanel <> TUTORPANEL) OR (LastPanel = HELPPANEL AND HELPPANEL_NeedsStackBackup = True) OR _

(LastPanel = TUTORPANEL AND TUTORPANEL_NeedsStackBackup = True) Then


Done = False

EventCounter = 0


Do While Done = False

' Throw away multiple LastPanels that are all the same


If STACK(STACK_Pointer) = LastPanel Then


STACK_Pointer = STACK_Pointer - 1

DEBUG1("Activity_KeyPress() KEYCODE_BACK - Subtracting 1 from Stack Pointer")

Else

Done = True

End If


If STACK_Pointer = 0 Then Done = True


If EventCounter Mod 3 = 0 Then

DEBUG1("Activity_KeyPress() KEYCODE_BACK - DoEvents")

DoEvents

End If

EventCounter = EventCounter + 1

Loop

End If


If STACK_Pointer <> 0 Then

DEBUG1("Activity_KeyPress() KEYCODE_BACK - STACK_Pointer = " & STACK_Pointer)



' Pull Panel off the Stack and jump to it


Dim OldStackPointer As Int = STACK_Pointer


If (LastPanel <> HELPPANEL AND LastPanel <> TUTORPANEL) OR (LastPanel = HELPPANEL AND HELPPANEL_NeedsStackBackup = True) OR (LastPanel = TUTORPANEL AND TUTORPANEL_NeedsStackBackup = True) Then

STACK_Pointer = STACK_Pointer - 1

DEBUG1("Activity_KeyPress() KEYCODE_BACK - STACK(" & OldStackPointer & ") = " & PANELNAMES(STACK(OldStackPointer)))



FLAG_LastPanelLoaded = LastPanel

CallSubDelayed("", MenuClicks(STACK(OldStackPointer)))

DoEvents

End If


Else If pnlWB.Visible = True Then

If WebViewWB.Visible = True Then

' If WB Question Panel is open, close it


CloseWBQuestion("")

Else

If pnlLock.Visible = False Then

TurnOnDimmedPanel("")



Answ = DialogResponse.CANCEL

EventCounter = 0


Do While Answ = DialogResponse.CANCEL



Answ = Msgbox2("Do you want to quit the program ?", _

"A T T E N T I O N", "Yes", "", "No", Null)



If EventCounter Mod 3 = 0 Then

DEBUG1(" - DoEvents")

DoEvents

End If


EventCounter = EventCounter + 1


Loop


If Answ = DialogResponse.NEGATIVE Then

DEBUG1("KEYCODE_BACK - Dialog Response NO pressed")

TurnOffDimmedPanel("")

Else

DEBUG1("KEYCODE_BACK - Dialog Response YES pressed")

If Not(IsPaused(Overlord)) Then StopService(Overlord)

Activity.Finish

End If

End If

End If

Else


' They aren't on the WorkBook panel, so back up to main panel

' Ensure that they didn't just come from Overlord

' If they did, this aborts Overlord's RestoreActivity


StartUpLesson("")

End If

End If


DoEvents

DoExit("Activity_KeyPress()")

Return True

End Sub

As I read through the code, the only part which confused me was the part about the HELP or TUTOR panels being at the top. In that case, they have a menu at the top of the HTML code, so if the user presses the phone's backup button, I want them to see the menu first, then back-up if they press it from that menu.

Besides that? I'd say if I didn't know a thing the subroutine did, I would afterwards.

Wordy-as-Hell? Yep. But, I'm 62 years old. The next time I go back to that code, am I going to remember exactly what it did? ... definitely not.

How does one write such a gigantic software when my mind isn't perfect like it used to be? Well, this is one of the tricks. It's a lot like the movie "Mementos" where the guy had 10 seconds of memory so he would tattoo his body with clues so he'd remember important things. Great movie, by the way, if you've never seen it before.
 
Last edited:
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
Use the controls at the top of the debug window, press the play button to continue, the second button to step to the next line or the stop button to exit the session.

View attachment 26417


Got a question about posting code. Is there some way to preserve tabs that I don't know about? Whenever I paste things, all the indents disappear; so I have to go line-by-line adding spaces (tabs don't work) to move all the lines over again.

If I used a different browser, or pasted it into some other program before pasting it into this Forum... would it preserve the tabs, somehow?
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
Use the controls at the top of the debug window, press the play button to continue, the second button to step to the next line or the stop button to exit the session.

View attachment 26417

So, the place where I'm asking it to please crash my program is:

Dim LIB_Strict As StrictMode

LIB_Strict.EnableStrictModeForAll(False,False)

"Is that a bad thing?" as George would say.

"Should I not have done that?"

I think it's also called, "Playing with matches."

So, yes, it's probably a good thing. However, if I can't understand what it's saying to me, that's not probably a good thing. ;)

I added that back when I was checking their memory and informing them when their memory wasn't big enough to run my program.

Guess it means my program works pretty well; as I've been running in Strict mode with no crashes, most of the time.

How do I catch strictmode triggers? Can I use:

Try
Catch

in some way to better interpret those error codes?

...

Lets turn off strict mode and see what happens.
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
When you have found the error you will have to remove all those "DoEvents" - I hope you have a copy that does not contain them!

In the Log window, try to uncheck the Filter

And why were you saying that I had to remove all those DoEvents?

I know that they tend to slow-down things if you're inside a loop; and in that case I always do an if counter mod 3 = 0 then DoEvents instead of just a plain DoEvents.

Is there something I don't know about putting in too many DoEvents besides that? Can too many DoEvents spoil the broth?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I don't normally experience this issue, tabs are usually maintained. (Using chrome browser)
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
Anybody know what happens, with Android, if a timer routine tries modifying the text of an EditText box at the same time as the main code tries modifying it? (I don't think that's occurring... but it's the only thing I can think of why it should crash while updating ten different panel's Countdown text boxes, one-after-the-other.)

It definitely seems to be the routine where it dies, though.

I'll set debug points there and see what's happening.

If the problem is that you update one EditText box, then another before the system can finish (or something) then setting debug points probably won't show it because the speed problem is eliminated by the debugger stopping the code so it's not bottlenecked any more. Maybe if I stick a DoEvents between each update of each EditText's text information it will slow it down enough so it doesn't crash.

Anybody know why updating ten successive EditText panel text should cause a crash from a timer routine?
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
So, looks like there's a handy log file at data/anr/traces.txt

Lets see what it says.

Know of any others?
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
Anyways, that gave me tons of new possibilities that will help me track down the problem.

Seems like the overlord service module is getting in a closed loop somehow.

I have 'sticky service' turned on for it.

From hidden logs (excerpts):

B4X:
Timeout executing service: ServiceRecord{4379f7e8 u0 b4a.acim/.overlord}

...

Wrote stack traces to '/data/anr/traces.txt'

...
(keeps trying)

...

Reason: Executing service b4a.acim/.overlord

Load: 5.71 / 5.24 / 5.13

CPU usage from 20445ms to 0ms ago with 99% awake:

8.2% 19998/b4a.acim: 6.3% user + 1.9% kernel / faults: 88 minor

Then the CPU usage seems to really dip... that's probably when it is analyzing the queue timings...

B4X:
CPU usage from 2473ms to 3001ms later with 99% awake:

21% 19998/b4a.acim: 14% user + 7.1% kernel / faults: 1473 minor

So, how can I find out what those 1473 "minor faults" were?

But, I can turn off the overlord, and that annoying requester continues. It might be because sticky services are turned-on so the overlord doesn't quit service module for a very long time. Will have to turn off Overlord and reboot. Then see if it still gets stuck.


If not, then it's something in the Overlord module.

If it does, it's not the overlord.

I certainly need to find out what those 1473 minor faults might be. That can't be good.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Lets pick any random subroutine. I'd bet that without seeing any other subroutine, you can easily figure out what the code is doing:

B4X:
Sub Activity_KeyPress(KeyCode As Int) As Boolean 'Return True to consume the event
............

If (LastPanel <> HELPPANEL AND LastPanel <> TUTORPANEL) OR (LastPanel = HELPPANEL AND HELPPANEL_NeedsStackBackup = True) OR _
     (LastPanel = TUTORPANEL AND TUTORPANEL_NeedsStackBackup = True) Then
     Done = False
     EventCounter = 0

     Do While Done = False
         ' Throw away multiple LastPanels that are all the same
         If STACK(STACK_Pointer) = LastPanel Then
             STACK_Pointer = STACK_Pointer - 1
             DEBUG1("Activity_KeyPress() KEYCODE_BACK - Subtracting 1 from Stack Pointer")
         Else
             Done = True
         End If

         If STACK_Pointer = 0 Then Done = True

         If EventCounter Mod 3 = 0 Then
             DEBUG1("Activity_KeyPress() KEYCODE_BACK - DoEvents")
             DoEvents
         End If

         EventCounter = EventCounter + 1
     Loop

End If
............
Do While Answ = DialogResponse.CANCEL
     Answ = Msgbox2("Do you want to quit the program ?", _
                               "A T T E N T I O N", "Yes", "", "No", Null)
     If EventCounter Mod 3 = 0 Then
         DEBUG1(" - DoEvents")
         DoEvents
     End If
     EventCounter = EventCounter + 1
Loop
............

I'm just spit-balling here in the hope that it might give you a new direction to go in, I'm only a hobbyist programmer and there's far more experienced people here on the forum. It looks to me like its possible for your code to get stuck in an endless loop if STACK_Pointer is not at the value you expect it to be.
B4X:
If STACK_Pointer = 0 Then Done = True
I'm always inclined to use "<= 0" in any comparison instruction to ensure that if the value goes negative then I can still continue with the program execution. Maybe the problem isn't in this routine, but if you've done the same in other routines then its something that could be looked at?

I've also never seen a MsgBox programmed this way, there is no need for the Do While loop. The MsgBox will halt program execution until the user presses an option or cancels. Below is the example usage given in the docs.
Msgbox2 (Message AsString, Title AsString, Positive AsString, Cancel AsString, Negative AsString, Icon As android.graphics.Bitmap) AsIntShows a modal message box with the specified message and title.
Message - The dialog message.
Title - The dialog title.
Positive - The text to show for the "positive" button. Pass "" if you don't want to show the button.
Cancel - The text to show for the "cancel" button. Pass "" if you don't want to show the button.
Negative - The text to show for the "negative" button. Pass "" if you don't want to show the button.
Icon - A bitmap that will be drawn near the title. Pass Null if you don't want to show an icon.
Returns one of the DialogResponse values.
Example:Dim result AsInt
result = Msgbox2("This is the message", "This is the title", "Good", "", "Bad", LoadBitmap(File.DirAssets, "smiley.gif"))If result = DialogResponse.Positive Then ...

I hope this gives you something more to look at and that you soon find the fault. I know just how frustrating some of these faults can be to track down :confused:

Kind regards,
RandomCoder
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
I'm just spit-balling here in the hope that it might give you a new direction to go in, I'm only a hobbyist programmer and there's far more experienced people here on the forum. It looks to me like its possible for your code to get stuck in an endless loop if STACK_Pointer is not at the value you expect it to be.
B4X:
If STACK_Pointer = 0 Then Done = True
I'm always inclined to use "<= 0" in any comparison instruction to ensure that if the value goes negative then I can still continue with the program execution. Maybe the problem isn't in this routine, but if you've done the same in other routines then its something that could be looked at?

I've also never seen a MsgBox programmed this way, there is no need for the Do While loop. The MsgBox will halt program execution until the user presses an option or cancels. Below is the example usage given in the docs.


I hope this gives you something more to look at and that you soon find the fault. I know just how frustrating some of these faults can be to track down :confused:

Kind regards,
RandomCoder


Thanks so much for your input. That's only gone to when they press their phone's back button; but you're right... it should be <=. Didn't notice that.

The problem, I'm sure, has to do with loading the one thread down with so many things. If I can move just the TIMER_Queue routine to a new thread... I'm sure that is the one. Also, there's another one which builds the queue that is a definite problem.

Everything else is event driven.

The problem is this: They can be doing anything they want to do. They can be going forward and backward through the lessons. All the time they're doing that, the queue has been built (which puts from 2 to 288 timing events into the queue for the timer to bring up later. They're all coded because there are about 30 different kinds of things it has to do when it finally triggers. Thus, the timer queue is waiting for the 'next event'. However, if they are going forward and backward through the lessons, it shouldn't build the queue until they are done looking forward and backward. So, a timer goes off to count 3 seconds each time they go forward or backward. Until they stop for 3 seconds, it doesn't rebuild the queue.

Once it has determined that the person has decided upon a lesson... it has to start building the queue in the background. But what if they continue moving forward and backward through the lessons?

Or, what if it goes into pause while it's rebuilding the queue?

And then there's the queue interpreter timer (the TIMER_Queue)... it must wait until the queue is done being built before it can continue. Then there's the OVERLORD_TIMER_Queue. It's just the same as the TIMER_Queue; but kicks-in when the phone goes into pause.

But what if they press their phone's 'go to sleep' button? And, what if a timing cycle is missed? How can one know if it has gone past the timing event?

There are a ton more problems than just those... but you get the picture.

There are ten different panels they can go to, for example, and they can go forward and backward through the main text as well as the lesson text as all this is going on. Or, they can go to either of two Table-of-Contents, or the Help page, or the Tutorial page, etc.

The user has about 50 different choices that he can make on the Settings panel; so he might be there.

And it remembers the scroll position for every one of those pages (there are 365 lessons and 284 chapters/sections). So, the number of things it is doing is almost beyond belief.

...

Out of everything, though, the ones that are problematic are the TIMER_Queue, the OVERLORD_TIMER_Queue and the DoBuildTimer() routines.

The DoBuildTimer() is definitely the one which causes problems because it has to be completely asynchronous with everything both the user and the phone is doing. It has to handshake properly with both the TIMER_Queue and the OVERLORD_TIMER_Queue.

The thing that's amazing is... all of this is generally nicely delicately balanced. It's only been the last couple weeks that it's gone all haywire; and I can't figure out what I did. Can't easily back-up to former versions because I add an enormous number of bug fixes and changes per-day; so I'd lose a ton of additions I made.

But knowing to turn off the filter and now knowing how to use the debug mode both should help, enormously.

Programming is a lonely, daunting, task sometimes and it's good to have people who are so supportive when the dark recesses of the App programming world seem to thwart us and cold winds blow for a time. It'll be so good once I find what's causing the problem.

The answer when a bug eludes for weeks is usually to change the manner in which you do it completely. And, making a new thread for the TIMER_Queue, OVERLORD_TIMER_Queue and DoBuildTimer() routines seems to be the next step. Can't hurt.
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
I'm just spit-balling here in the hope that it might give you a new direction to go in, I'm only a hobbyist programmer and there's far more experienced people here on the forum. It looks to me like its possible for your code to get stuck in an endless loop if STACK_Pointer is not at the value you expect it to be.
B4X:
If STACK_Pointer = 0 Then Done = True
I'm always inclined to use "<= 0" in any comparison instruction to ensure that if the value goes negative then I can still continue with the program execution. Maybe the problem isn't in this routine, but if you've done the same in other routines then its something that could be looked at?

I've also never seen a MsgBox programmed this way, there is no need for the Do While loop. The MsgBox will halt program execution until the user presses an option or cancels. Below is the example usage given in the docs.


I hope this gives you something more to look at and that you soon find the fault. I know just how frustrating some of these faults can be to track down :confused:

Kind regards,
RandomCoder


Well, the thing it brings to mind is... double-check every Until and While Loop that I have and ensure that they aren't getting stuck. However, now that I made the debug output so that it staggers with indents it is SO nice to be able to see every entry and exit to every subroutine visually. But, nope, I now can be sure that none are going into any subroutine but not exiting from that subroutine. Thus, the problem has to be somewhere else.

Being methodical is the trick. I now have a DoEvents in every subroutine, and every do while/until loop or for-next loop with an 'if counter mod 3 = 0 DoEvents'. Still gives me that annoying message.

What's annoying is, the App isn't locking-up. It's running nicely just as it always did. I just can't have an App that brings that requester up all the time (besides, it somehow means that it might be in an infinite loop somewhere).

Anyways, back to work. I took the weekend off - will now learn how to make new threads and what that means. By the end of today I should have put those three routines into their own threads. Would be nice if that gets rid of the problem; but I'll bet that after I do it? And each thread is working fine... it'll still do it.

Time will tell; certainly will be nice when it's working perfectly again. Programming is a lot like juggling a thousand balls in the air. It's also extremely like building a gigantic house of cards. Placing one card firmly against another is the trick. Once the house starts to fall, though? Ouch.
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
I'm just spit-balling here in the hope that it might give you a new direction to go in, I'm only a hobbyist programmer and there's far more experienced people here on the forum. It looks to me like its possible for your code to get stuck in an endless loop if STACK_Pointer is not at the value you expect it to be.
B4X:
If STACK_Pointer = 0 Then Done = True
I'm always inclined to use "<= 0" in any comparison instruction to ensure that if the value goes negative then I can still continue with the program execution. Maybe the problem isn't in this routine, but if you've done the same in other routines then its something that could be looked at?

I've also never seen a MsgBox programmed this way, there is no need for the Do While loop. The MsgBox will halt program execution until the user presses an option or cancels. Below is the example usage given in the docs.


I hope this gives you something more to look at and that you soon find the fault. I know just how frustrating some of these faults can be to track down :confused:

Kind regards,
RandomCoder

THAT was SO EASY.

I created 14 threads... one for each of the queue timer modules, one for the buildqueue routine and one for each of the panel handler subroutines. That made it run incredibly well and there is no longer that annoying requester popping up.

Yay.

I guess I had just made the program too big for it's britches and it was obliging (sort-of) in its extremely strained way.

Now, each menu choice works instantaneously, the build of the queue is extremely fast, the table of contents load like a dream. It had all got incredibly bottlenecked by it all being done in one thread.

Ah, that's over.

I'm going to create separate threads for each of potential timers, such as the duration timers which set off a sound when a certain amount of time has gone by after an event has triggered. You're supposed to contemplate what it says for x-number of minutes and the duration timer tells them when that has occurred.

Boy it's simple to create new threads. Wish I knew about this a long time ago.

Now I got to understand 'Lock' (Part of the threading library). I think it might come in handy when I'm building the queue (to possibly lock the QUEUE_Timer thread and the OVERLORD_QUEUE_Timer thread) until the BuildTimer() routine is done. Better than setting a flag.
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
I'm just spit-balling here in the hope that it might give you a new direction to go in, I'm only a hobbyist programmer and there's far more experienced people here on the forum. It looks to me like its possible for your code to get stuck in an endless loop if STACK_Pointer is not at the value you expect it to be.
B4X:
If STACK_Pointer = 0 Then Done = True
I'm always inclined to use "<= 0" in any comparison instruction to ensure that if the value goes negative then I can still continue with the program execution. Maybe the problem isn't in this routine, but if you've done the same in other routines then its something that could be looked at?

I've also never seen a MsgBox programmed this way, there is no need for the Do While loop. The MsgBox will halt program execution until the user presses an option or cancels. Below is the example usage given in the docs.


I hope this gives you something more to look at and that you soon find the fault. I know just how frustrating some of these faults can be to track down :confused:

Kind regards,
RandomCoder

So... looks like the threading library was designed way before things got nicer and shouldn't really need to be used.

I think I found what the problem was. I changed any CallSub( ) I still had remaining into CallSubDelayed( ) and the problem seems to have gone away. That would be nice if that's all the problem was.

I'll have to double-check that it's all working well; but so far so good.

Thanks so much for everbody's concern, suggestions and help. It taught me some things I needed to know (how to use the single-step debugger is a big one) and reminding me about the filter checkmark. Both of those are good things to remember.
 
Upvote 0
Top