Author Topic: JavascriptAddin using session.prompt causes EA to freeze  (Read 6080 times)

meeert

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
JavascriptAddin using session.prompt causes EA to freeze
« on: April 21, 2023, 04:43:35 pm »
Hi, the titles says it already.

I made the standard Example of the JavascriptAddin. However, the following behavior makes EA freeze.

EA_MenuClick

     Session.Prompt("You clicked " + ItemName, 1);

Not the intended behavior I assume?
I'm using version 16.1.1625 - 64 bit
« Last Edit: April 21, 2023, 05:14:31 pm by meeert »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8061
  • Karma: +118/-20
    • View Profile
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #1 on: April 24, 2023, 08:29:49 am »
The Javascript addins are running their code synchronously with EA, just like add-ins written in other languages.

If you show a message box in any language, the entire UI of the application is blocked, waiting for the call to return.

So yes, based on what you've described that is entirely expected.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1352
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #2 on: May 22, 2024, 07:44:28 pm »
Hi,

I'm having the same issue when calling Session.Prompt from a model-based addin.
Whilst I understand the addin is waiting for the user to click on a button e.g. OK, Yes, No... EA freezes for a few minutes preventing the user from doing anything.
Is there a workaround (code to add) to prevent this behaviour ?


Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


philchudley

  • EA User
  • **
  • Posts: 737
  • Karma: +20/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #3 on: May 23, 2024, 05:54:22 pm »
Hi

Yes me too!

I developed a Model based Add-in which uses Session.Prompt in addition to Session.Output

Both "freeze" with the "blue circle of death" ... eventually EA will respond to the user click, say OK in the Session.Output.

I have found, that when "freeze" happens, clicking the EA title bar, springs EA back into life and the user interact with the dialog. Not ideal.

As this was for a client, I reverted to write the addin as a conventional C# dll

Phil
follow me on Twitter

@SparxEAGuru

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1352
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #4 on: May 23, 2024, 11:10:24 pm »
Hi Phil,

Thanks for confirming the behaviour. Until this can be fixed, there could be a workaround involving a custom Javascript function to replace the Session.Prompt.

Update: I confirm that using a simple Javascript function fixed the issue.
Code: [Select]
//style:
// 0 -> OK button
// 1 -> OK/Cancel buttons
// 3 -> Yes/No/Cancel buttons
// 4 -> Yes/No buttons
// Returns a value matching the clicked button:
// 1 -> OK
// 2 -> Cancel
// 6 -> Yes
// 7 -> No

style += 4096;
var WSH = new COMObject("WScript.Shell");
return WSH.Popup(prompt, 0, title, style);

I published an article about a Model Based Addin example: https://www.umlchannel.com/en/enterprise-architect/item/359-enterprise-architect-model-based-addin

« Last Edit: May 29, 2024, 04:15:12 pm by Guillaume »
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


DASHBY88

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #5 on: November 21, 2024, 08:05:32 pm »
I know this topic is dormant but thought I'd add.

We have only found this issue to be noticeable since transitioning from EA15.2 to EA16.1.

I will implement Guillaume's suggestion but this is a shame for the EA API, as I was looking forward to my prompts appearing on the right screen.

ea0522

  • EA User
  • **
  • Posts: 134
  • Karma: +5/-0
    • View Profile
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #6 on: November 25, 2024, 05:43:36 pm »
A while ago, I had a similar issue with EA Freeze in a different use case where there was a pop-up involved.
Turned out that the pop-up window was shown somewhere out of the visual screen boundary.
The issue was solved by using something like ctrl-M I believe which enables a Windows user to move a window around using the arrow keys. With this, the pop-up screen could be brought back into the visual part of the monitor again.
Problem solved...