2 semi-random? problems

Workarounds and usability notes.

2 semi-random? problems

Postby John Robin Dove » Tue Feb 09, 2021 11:22 am

Hi Clifton,
I have two problems I can't seem to solve.
1) Rarely occurs but sometimes does. I get this message:

Image

which is a serious problem because all execution ceases thereafter. I know it's to do with pgGotoURL. I found this out as I mentioned here https://www.pgsoftwaretools.com/forum/viewtopic.php?f=10&t=362 and wrote in my January 7th post: loading the two documents one after the other, using pgGotoURL, produces an error because the first document is not properly loaded before the second one arrives. but I can't see why the error occurs apparently randomly in other parts of the program. I use two two different fields ("screen1" and "screen2" to display the different parts of my program. There are a lot of these and generally each one is from a different exported tbk file. When I go from one part to another I use these scripts:
Code: Select all
   
  <function name="transition" event="" params="dest">
  <![CDATA[
    if (this.screenNo == 0)
    {
    tbfunction_changeObjectLayer("instructions_5", top);
    tbfunction_snapObjectToCenter("pleaseWait", "screen0", 2);
    tbfunction_pgTBObjSet("pleaseWait", "top", 680);
    tbfunction_pgTBObjSet("pleaseWait", "visible", true);
    this.screenName = "screen1"
    tbfunction_pgTBObjSet("gif", "visible", true);
    }
    else if (this.screenNo == 1)
    {
    this.screenName = "screen2"
    }
    else  if (this.screenNo == 2)
    {
    this.screenName = "screen1"
    }
   
    if (dest == "ss" || dest == "ts")
    {
    this.bColor = "191,255,255"
    }
    else if (dest == "vs" || dest == "vt1" || dest == "vt2")
    {
    this.bColor = "63,191,254";
    }
    else if (dest == "is" || dest == "it")
    {
    this.bColor = "192,220,192";
    }
    else if (dest == "as" || dest == "at1" || dest == "at2")
    {
    this.bColor = "253,253,189";
    }
    else if (dest == "tc")
    {
    this.bColor = "64,128,255"
    }
  tbfunction_pgGotoURL(this.screenName, "/programs/" + dest + "/index.html");
  ]]>
  </function>

 <function name="switchScreens" event="" params="">
  <![CDATA[
    if (this.screenNo == 0)
    {
    this.screenNo = 1;
    tbfunction_pgTBObjSet("speech", "visible", false);
    tbfunction_pgTimer("", "", "speech", true);
    tbfunction_fadeObject("screen0", "", "", 2500, 0);
    tbfunction_fadeObject("screen1", 2500, 100);
    tbfunction_pgTBObjSet("gif", "visible", false);
      var fct = function()
      {
      document.body.style.background = 'rgb(' + keys.bColor + ')';
      tbfunction_pgStyleObject("fondo", "backgroundColor", "rgb(" + keys.bColor + ")");
      tbfunction_pgTBObjSet("pleaseWait", "visible", false);
      }
    setTimeout(fct, 1250);
    }
    else if (this.screenNo == 1)
    {
    this.screenNo = 2;
    tbfunction_fadeObject("screen1", "", "", 2500, 0);
    tbfunction_fadeObject("screen2", 2500, 100);
      var fct = function()
      {
      document.body.style.background = 'rgb(' + keys.bColor + ')';
      tbfunction_pgStyleObject("fondo", "backgroundColor", "rgb(" + keys.bColor + ")");
      }
    setTimeout(fct, 1250);
    }
    else if (this.screenNo == 2)
    {
    this.screenNo = 1;
    tbfunction_fadeObject("screen2", "", "", 2500, 0);
    tbfunction_fadeObject("screen1", 2500, 100);
      var fct = function()
      {
      document.body.style.background = 'rgb(' + keys.bColor + ')';
      tbfunction_pgStyleObject("fondo", "backgroundColor", "rgb(" + keys.bColor + ")");
      }
    setTimeout(fct, 1250);
    }
  ]]>
  </function>

switchScreens is triggered by the destination page when it has finished loading.

2) When the page has loaded I sometimes get a wait cursor that refuses to go away until the user moves the mouse which is strange because the object that initiates the cursor change, a transparent field, is hidden as soon as the loading has finished. This usually happens after a video has been loaded but it doesn't always happen even when the same video is loaded. I guess it's not that serious but it is annoying. Apparently, from what I have read on Stack Overflow, this problem is not uncommon but I have't been able to use any of the suggestions I found.
Please let me know your thoughts. Thanks for your time.
John
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: 2 semi-random? problems

Postby Clifton » Tue Feb 09, 2021 12:19 pm

Hi John,

Regarding the first error. I'm going to post a possible fix for pgGotoURL() that may make the function a bit more graceful when calling the it repeatedly. You can check for the update in an hour or two.

Regarding the second issue, I would directly change the cursor to "default" when the event occurs instead of expecting the browser to do so in response to hiding an object. Hiding an object under a cursor does not always change the cursor state. So for example you could force this to occur by executing this CSS code before loading your window(s):
    tbfunction_pgStyleObject( this.name, "cursor", "-");
Hope these ideas help.
Clifton   ;)
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: 2 semi-random? problems

Postby John Robin Dove » Wed Feb 10, 2021 5:28 am

Thank you very much. I have installed your latest update. I haven't seen the error message but there again it only appeared very randomly like sometimes once a month or sometimes twice a week.

I'm not quite sure what you mean by making the function a bit more "graceful". Do you mean it's less likely to produce an error now? I hope so. :)

I have been able to fix the cursor problem. It demonstrated just how chaotic this project has become. It has a high level of redundancy. By that I mean there is unnecessary duplication of numerous functions and tools common to all pages. I intend to deal with all this later on but for the time being I'd like to just finish it in its current state. Originally each part was a separate html but expecting the user to navigate correctly between each page was too much to ask. So thanks to pgGotoURL :idea: there is now just one page into which all the 16 others are embedded. This is far more satisfactory as I can now control the user's navigation effectively.

Anyway, to cut a long story short :roll: , each page has a transparent field called "shield" that prevents the user clicking on things at crucial moments such as when the next page is loading. The cursor problem appaered when the shield on the embedded page was used but commanded by the top containing page. The cursor change was activated via pgExecuteRemote. In theory it should have worked but it didn't. So, in certain situations I now use the shield on the top page instead and the cursor behaves itself. Of course ideally there should only be only one shield instead of 17 but as I said this will be done later (famous last words).
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: 2 semi-random? problems

Postby John Robin Dove » Wed Feb 10, 2021 11:20 am

re. graceful etc. I hope you were not offended. I was not underestimating your abilities! I just wanted to know if you think the problem is fixed.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: 2 semi-random? problems

Postby Clifton » Wed Feb 10, 2021 11:40 am

There is some maintenance that pgGotoURL() does once the window has opened. In your case, immediately re-executing the function may not allow enough time for the maintenance to be performed, thus throwing the error. Maybe the fix will work. It certainly won't hurt anything. The function gracefully fails after opening a window that no longer has any content to manipulate.

Does the problem still appear?
 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: 2 semi-random? problems

Postby John Robin Dove » Wed Feb 10, 2021 12:07 pm

Thanks for your reply. No, the error has not appeared since your update but as I said before, it was a very random error. You might have to wait a month before seeing it again. If it does come back I could try the system I used to detect loading I described here https://www.pgsoftwaretools.com/forum/viewtopic.php?f=10&t=362 (jan 07) This has never failed. In this case I would add a function to my pages to signal the moment when they have finished loading.
UPDATE
Sorry I'm getting confused again. :roll: The last sentence was nonsense because my system already functions like this i.e. it waits for one page to finish loading before starting to load the next one. What I could do, if the error comes back, and there is no reason to think that it will, is wait an extra second before starting to load which is what I do in when loading a cross domain page.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron