1. Mark Jones
  2. PowerBuilder
  3. Friday, 29 April 2022 13:58 PM UTC

PB 2021 - build 1506.   I am posting this issue to Q&A so others are aware of it but I am also submitting this as a bug.

We have been trying to reproduce this issue consistently - it seems to happen frequently within our main application and only occasionally with a test bed application.    Basically if we open a userobject on a window containing a webbrowser and then close it , it will sometimes fire a close event on the parent application!     This is intermittent enough to be very annoying.   It is not Themes related.  It is not related to navigation (it still occurs if we do not navigate)  The issue occurs in both the compiled application and the IDE.

I have found that it does seem to consistently occur if I close the IDE and then reopen and immediately launch the test bed application.  I will report this as a bug since it seems it can be recreated by closing the IDE and reopening...

Here is our testbed code.

We have an instance variable on the window like this:

    webbrowser i_webbrowser

 

And two buttons on the window.

    [Open Webbrowser] with the code:

 parent.openuserobject(i_webbrowser)
i_webbrowser.visible=TRUE
i_webbrowser.x=500
i_webbrowser.y=500
i_webbrowser.width=1000
i_webbrowser.height=1000

i_webbrowser.navigate("http://www.appeon.com")

    

And [Close Webbrowser] with the code:

parent.closeuserobject(i_webbrowser)

Open the window, click the open Web Browser button.  The Appeon web page appears.  Hit the close Web Browser button and then the entire application closes.   

 

 

 

Mark Jones Accepted Answer Pending Moderation
  1. Friday, 29 April 2022 17:17 PM UTC
  2. PowerBuilder
  3. # 1

Mark, thanks for the response.   This is a great workaround.  I am wondering if I can also send a cancel to the loading of the web page right before the closeuserobject to ensure that if the web page is having trouble loading it will not hang forever.   

However what is strange is that this issue will sometimes occur if I do not even navigate to a web page -  I have no idea why that would be.

Did you report this as a bug?   I have done so but if you have already reported it and have a case # I can update my report.

Mark

Comment
  1. Chris Pollach @Appeon
  2. Friday, 29 April 2022 17:37 PM UTC
Hi Mark .... I received your Support Ticket:

A) I can replicate the bug in my W10 and W11 test machines on the latest build 1509 and

B) even if you wait for the web page to be fully loaded and then close the UO - if you do this repeatedly - the app will eventually crash!

I have transferred your ticket on to Engineering for a deeper investigation.
  1. Helpful 2
  1. Mark Jones
  2. Friday, 29 April 2022 17:43 PM UTC
Thanks for the update Chris.
  1. Helpful
  1. Mark Goldsmith
  2. Friday, 29 April 2022 17:55 PM UTC
You're very welcome Mark and thanks Chris for looking into this. Notwithstanding Chris's response...as for canceling a web page downloading, you may be able to issue window.stop(); in JavaScript as well. You may also be able to issue a Navigate("") but this will also cause the issue if you try to close the object too soon so you'll still require a delay or check the readyState (which may be why you sometimes experience this behaviour even when you don't navigate anywhere but have opened the user object). I'm not sure if the CancelDownload() would work in this case...maybe...but you'll have to obtain the ItemID from the DownLoadingStart event and store it in an instance variable.

No, I haven't entered a bug for this issue.
  1. Helpful
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Friday, 29 April 2022 16:58 PM UTC
  2. PowerBuilder
  3. # 2

Hi Mark,

I wonder if what you're experiencing is a timing issue with a document not being fully loaded but even still, PB should not be responding that way. I'd prefer an error that you could hopefully manage in a Try/ Catch versus just closing the app.

If you put a Sleep(1) before the CloseUserObject() that may make a difference...it did for me.

You could also check the readyState of the document via JavaScript to see whether the document is complete before issuing a CloseUserObject(). The code for that would look something like:

String ls_result = "", ls_java = "document.readyState === 'complete'"
Boolean lb_complete = False

Do While lb_complete = False
	If  POS(ls_result, "true") = 0 Then
		i_webbrowser.EvaluateJavascriptSync(ls_java, ls_Result)
	Else
		lb_complete = True
	End If
Loop
Parent.CloseUserObject(i_webbrowser)

Either of the above does work with PB 2019 R3 B2703.

HTH...regards,

Mark

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.