1. András Balázs
  2. PowerBuilder
  3. Thursday, 24 August 2023 14:43 PM UTC

Hi Everyone,

 

I am trying to migrate my app from CEF to the new Webview2 control.

I could manage to navigate to the desired html, load its javascript, register a PB user event, trigger the user event from Javascript and call EvaluateJavascriptAsync from PB. The only missing step for me is calling EvaluateJavascriptSync from PB (outside the registered event !), which actually immediately kills the IDE and the debugger.

Code like below seamlessly worked in CEF:

string js_command, js_result, js_error

int ret

ret = wb_1.EvaluateJavascriptSync('js_function("params");', ref js_result, ref js_error)

ret = wb_1.EvaluateJavascriptSync('javascript:js_function("params");', ref js_result, ref js_error)

At such places the async function works, but it would be much more convenient to use the sync one (e.g. for error checking).

Does any of you have gone through a similar exercise?

What are the constraints for using the sync function? Can you use it in the new control anyway?

Any help would be highly appreciated.

 

András Balázs

 

 

 

 

 

Kai Zhao @Appeon Accepted Answer Pending Moderation
  1. Friday, 25 August 2023 02:18 AM UTC
  2. PowerBuilder
  3. # 1

Hi András,

This is a limitation of the webview2 solution. You can find the note below in PB help.
https://docs.appeon.com/pb2022r2/pbug/Defining_user_events_for_WebBrowser.html

In the registered PowerBuilder user event, only the asynchronous function EvaluateJavascriptAsync can be called; it is not allowed to call any other WebBrowser functions.

Regards,
Kai

Comment
  1. András Balázs
  2. Friday, 25 August 2023 03:59 AM UTC
Kai,



Thanks for your comment, but as I wrote I try to use the sync function outside the registered event.



András
  1. Helpful
  1. Kai Zhao @Appeon
  2. Friday, 25 August 2023 06:06 AM UTC
Though you use the sync function outside the registered event, you call it through the registered event so it still has the problem. You can try post call it to work around the issue.

  1. Helpful 1
  1. András Balázs
  2. Friday, 1 September 2023 10:48 AM UTC
Kai,



You are right, it is easy to avoid the whole problem by moving the script to an object function of the window containing the web browser control and leave a POST in the event. However the same function works without problem in the navigationcompleted event of the control, and further to that you can freely use the Navigate function inside the registered event, which disturbs the picture a little bit.

Anyway It is far from being the end of the world, the rules of usage might be clearer in the documentation.



András

  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 24 August 2023 19:31 PM UTC
  2. PowerBuilder
  3. # 2

Hi András;

  If the App you have can be used as a test case, I would then suggest that you open a Support Ticket & attach this PB App to the ticket so that Engineering can do a deep dive on this crashing.

Regards ... Chris 

Comment
  1. András Balázs
  2. Friday, 25 August 2023 04:04 AM UTC
Chris,



Thanks for your comment. I prepare a test case, but it will take a little time as it is a quite large app.



András
  1. Helpful
  1. András Balázs
  2. Friday, 1 September 2023 10:11 AM UTC
Chris,



Following your guidance I prepared a test app demonstrating the issue. Before opening a Support Ticket, let me raise a question.

The essence of the story is that I used the titletext event of the CEF control to create markers for a map at loading the JS script using the EvaluateJavascriptSync function. It was working without problem, but it freezes the world in the new control. The same function works well in the in the navigationcompleted event of the new control. I feel discouraged if it is a bug or just a feature of the new control. In other words, do you expect 100% compatibility of the new control, or is it just a frog we have to swallow (this is the equivalent of we have to live with it in Hungarian)?

Anyway it is very easy to avoid the problem by moving the code to an object function outside the browser and POST it in the event.

Do you see it as a bug or a feature? :-)



András
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 1 September 2023 14:11 PM UTC
Hi András;

I suspect that this issue is caused by a discrepancy between the two different web engines (Chromium vs WebView2).

A support ticket with this type of test case should allow our Appeon Engineering team to trace the issue internally. to get to the bottom of this problem.

Regards ... Chris
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 24 August 2023 16:45 PM UTC
  2. PowerBuilder
  3. # 3

Probably not much of a help, but just FYI, I've seen more people complaining about webview2 and the non-async call.

 

See: https://www.appeon.com/standardsupport/search?comments=EvaluateJavascriptSync&product=&component=&criteria=and&order=

Comment
  1. András Balázs
  2. Friday, 25 August 2023 04:00 AM UTC
Miguek,



I feel much better now. :-)



András
  1. Helpful 1
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.