Have you tried using EvaluateJavaScriptAsync? If not, I suggest you try it.
Although you have not described what action(s) you are performing in JavaScript, the code snippet you posted leads me to believe that you are opening/using an editor of some kind. I know the documentation says to not use EvaluateJavaScriptSync when a dialog box will be opened, but I believe the critical concern has to do with initiating an action that writes to the screen/display in any manner, not limited solely to a dialog box. I say this because of my experience with learning about using Apache Echarts from PB and adapting the Appeon-supplied charting example application for use in our product.
The charting example utilizes EvaluateJavaScriptAsync in order to accomplish what needs to be done, so it makes me think this might be the cause of the problem. Worth a try, in my estimation.
Best regards, John