Anybody encounter this? All objects on page invisible

Topics related to using ToolBook for building web apps.

Anybody encounter this? All objects on page invisible

Postby Andy » Tue Sep 07, 2021 10:40 am

I'm seeing instances where the page seems not to load, although in fact it does load but all its objects are invisible. Because this happens intermittently I suspect some kind of race condition in the scripts. It does seem to happen more frequently when the previous page contains calls to a larger set of actions, in particular those including SCORM calls.

I've tried adding delays in the hope that any long-running scripts will have time to complete, but to no avail. Is there some technique by which I can detect the completion of running scripts?

Finally, is it normal behavior for the page to be loaded and then made visible? Is there something I can do to make sure everything shows?

Thanks, Andy
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: Anybody encounter this? All objects on page invisible

Postby Clifton » Tue Sep 07, 2021 11:10 am

Does this happen in one particular browser?
Does the page load and show all objects when it is not connected or launched from the LMS?
  • If it loads when not connected, then the SCORM calls may be locking up the browser. You can check this by opening the Task Manager and checking to see if the browser is spiking the CPU.
  • If the above is true, then verify that the SCORM calls are configured correctly. If they are locking the browser, then moving them to a point after the DOM loads (which essentially is on load for the first background—not the on load event for the page) may help.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Anybody encounter this? All objects on page invisible

Postby Andy » Wed Sep 08, 2021 11:08 am

Thanks, Clifton, for your tips on isolating the problem. Here is an update.
As I backed out my recent changes, my suspicion of the SCORM calls turned out to be a red herring.
What appears to be happening has to do with the audio that plays on page enter. The audio end event does not trigger.
After that, further calls to pgSoundLoader don't replay the audio, and I get the side effect of invisible objects on the next page.
Interestingly, if I use pgSoundControl to stop the audio before it completes, everything is good.

This happens in an old book that has been working for years. I see it on Firefox and Chrome.
Since the book is very large I will now try to come up with a small example that will be easier to debug.
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: Anybody encounter this? All objects on page invisible

Postby Clifton » Wed Sep 08, 2021 11:30 am

Audio is NOT played by default in modern browsers unless the user clicks somewhere (anywhere actually) on the page. This has the effect of satisfying the browser's security provisions and indicates that the user wants to interact with the page, thus allowing audio to play. When auto-playing audio, the user must interact with the page BEFORE the auto-play mechanism starts playing the audio, otherwise the audio will need to be unmuted by user intereaction. This is how many news websites work.

For ToolBook apps, the user only has to interact with the first page displayed; even if there is no audio on that page. If you are trying to play audio when the first page loads, then the browser's security provisions will block it, no audio will play and no events will be triggered. Interestingly, the progress bar will generall move even though the sound is blocked. But when the user interacts with the controls, the browser will unblock the sound and allow notification events.

IE11 may not follow this, but with curent development going on in Windows, IE11 is very soon to be obsolete (a good thing really).

Nevertheless, Chrome, Firefox, and Edge all block audio until the user interacts with the page in some way.

The easiest way to get around all of this is to a create splash page for your courses. Somewhere on the page you can include a button that the user simply clicks to enter the course. This will move to the first page of the course and all audio will automatically be unblocked and play nicely for the rest of the session—even if it is set to autoplay. Works in all browsers too!

I read an article on a courseware development site on another way to get around this. However, I remember feeling that the method probably would hold up over brower development as it was quite a hack. Hacks only work for a short time before browsers figure out what people doing.

Hope this helps.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Anybody encounter this? All objects on page invisible

Postby Andy » Wed Sep 08, 2021 12:37 pm

Hi Clifton, you are right that normally a TB book needs some kind of click before audio will play automatically, and yet that was what I was observing... until I rebooted my PC. Now that part is behaving. But still there is no audio end event from powerpac when the audio file is allowed to play to its completion. And the fact that it interferes with the following page is just bizarre.

If I can reproduce this in my small test case I'll try calling pgSoundControl to see if it thinks the audio is still playing. There is also the size of the book. I wonder if I am at the point where any change to the book will require me to run a repair. Yes, I thought about switching to your XML model, but there are several hundred pages that would have to be converted. This was supposed to be a quick tweak to an old project!
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: Anybody encounter this? All objects on page invisible

Postby Clifton » Wed Sep 08, 2021 2:19 pm

Hi Andy,

If the sound is being heard and the end of audio is not being triggered, you may want to verify that the sound controller is sending the user event to the correct object.

Example:
Let's say I want to play an audio file named "myaudio.mp3" ... and the object that is the target of the audio playback is a field called "SampleAudio" ...
  • To play the audio: (following action could be placed on any object or on the page)
    on load page
    pgSoundLoader( "../[audio folder]/myaudio.mp3", "SampleAudio", "", "play", false, 100, false, "", true );
  • For the on user event for the field "SampleAudio":
    on user event ... (Parameters: value)
    if value contains "end"
    //Navigate to a specific page or do some other task when audio finishes
    Display alert: "Audio ended: " & value
    end
I've run an exact sample of the above actions. If I click on the "Loading ... please wait" message, the audio plays immediately on the loading of the page and the end of audio event is triggered as expected.

Hope this helps!
 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Anybody encounter this? All objects on page invisible

Postby Andy » Thu Sep 09, 2021 10:52 am

Hi Clifton, thanks for your help. Here is an update:
I repaired the book and reinstalled PowerPac.
I explicitly set all default values for pgSoundLoader as you have done in your example.
I've clicked on the book as it is loading to avoid the initial error when it tries to play but is denied.
I rebuilt the audio file to clean up any strangeness.
I've tried two different browsers and two different PCs.

Nothing helped. Here are results of some experiments:
I hear the audio but don't get the "audio,end" event when it reaches the end.
Time marker events are sent to where I expect, so it could be that the device driver is the problem.
Calls to pgSoundControl tell me that the status before playing is 1 and after reaching the end is 0.
The status remains at 0 after a pgSoundControl stop command.

I think that the invisible page is caused by the audio in its confusion stealing focus or something, so the audio is the root problem.
This same audio handling works in other books including the previous version of this one, so I need to figure out what's so special about this case.
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: Anybody encounter this? All objects on page invisible

Postby Clifton » Thu Sep 09, 2021 1:18 pm

Please post your user event actions so we can take a look. If you are handling time markers AND end of audio events it could be that the action logic is bypassing something.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Anybody encounter this? All objects on page invisible

Postby Andy » Thu Sep 09, 2021 2:18 pm

I added the time marker as a test. This book does not normally use them.

How do you export the parameters to the script calls? The Show Page Actions command leaves them out.
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: Anybody encounter this? All objects on page invisible

Postby Andy » Thu Sep 09, 2021 3:09 pm

Global variable aud is set to 0

--------------------------------------------------------------------------------
Actions for Button "aPlay" of Page "Start"
--------------------------------------------------------------------------------

-- On click... -----------------------------------------------------------------
Define local variable "audioFile" (Initial value: "")
Define local variable "m" (Initial value: "")
Define local variable "markers" (Initial value: "")

If not isNumber ( aud )
Break out of action sequence
End if
If aud = 0
Set audioFile to text of field "Audios"
If charCount ( audioFile ) > 0 and audioFile <> "none"
Execute Script pgSoundLoader (HTML) ("../Audio/" & item 1 of audioFile, "Audios", defaults)
Set visible of Button "aStop" to true
Set visible of Self to true
End if
End if


--------------------------------------------------------------------------------
Actions for Button "aStop" of Page "Start"
--------------------------------------------------------------------------------

-- On click... -----------------------------------------------------------------
Send User event to Field "Audios" with value: "audio,end"
Execute Script pgSoundControl (HTML) ("Audios", "stopAll")
Set visible of Self to false


--------------------------------------------------------------------------------
Actions for Field "Audios" of Page "Start"
--------------------------------------------------------------------------------

-- On User event... ------------------------------------------------------------
Define local variable "timer" (Initial value: "")

Set timer to item 2 of value
If not isNumber ( timer )
Comment: Audio End event
Set visible of Button "aStop" to false
End if
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Next

Return to Web (DHTML) Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron