Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible timing issue with JavaScript loading #4416

Closed
ebruchez opened this issue Feb 8, 2020 · 6 comments
Closed

Possible timing issue with JavaScript loading #4416

ebruchez opened this issue Feb 8, 2020 · 6 comments

Comments

@ebruchez
Copy link
Collaborator

@ebruchez ebruchez commented Feb 8, 2020

I haven't reproduced it yet. But it appears that when the first of our large JavaScript files terminates first, we get a JavaScript error.

We set the 4 main scripts with defer.

<script 
    type="text/javascript"
    src="/demo/xforms-server/7e9767a99aeb7f344a3a64cc4d16d194dc1c435f/orbeon-3fd829d169eea2ea2f399c5d2d9f23632862abf5.js"
    defer></script>
<script 
    type="text/javascript"
    src="/demo/xforms-server/7e9767a99aeb7f344a3a64cc4d16d194dc1c435f/orbeon-88e714f3615fd67547b07d02cd1dd2a07b4fcc17.js"
    defer></script>
<script 
    type="text/javascript" 
    class="xforms-standalone-resource" 
    defer
    src="/demo/xforms-server/form/static/395787fd34f746f092fbc7f1cc623d431534d90c.js"></script>
<script
    type="text/javascript" 
    class="xforms-standalone-resource" 
    defer
    src="/demo/xforms-server/form/dynamic/f72a16d0f67c518103a61742f7a607088dcf1894.js"></script>

The scripts are:

  1. baseline
  2. additional
  3. static
  4. dynamic

In the case that fails, the end of loading order is:

  1. static
  2. dynamic
  3. baseline
  4. additional

In the successful cases:

  1. static
  2. dynamic
  3. additional
  4. baseline

According to MDN:

Scripts with the defer attribute will execute in the order in which they appear in the document.

This indicates that the time of termination of a script should not change the execution order.

Next steps:

  • enable HTTP proxy (or use Thread.sleep() in the right place) to see if we can reproduce the issue locally

+1 from customer

@ebruchez ebruchez self-assigned this Feb 8, 2020
@ebruchez ebruchez added this to To review in Orbeon Forms 2020.1 via automation Feb 8, 2020
@avernet

This comment has been minimized.

Copy link
Collaborator

@avernet avernet commented Feb 8, 2020

BTW, I do reproduce this, and for me happens quite frequently.

@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

@ebruchez ebruchez commented Feb 8, 2020

@avernet with Safari, I assume?

@avernet

This comment has been minimized.

Copy link
Collaborator

@avernet avernet commented Feb 8, 2020

@ebruchez Correct.

avernet added a commit that referenced this issue Feb 8, 2020
@avernet

This comment has been minimized.

Copy link
Collaborator

@avernet avernet commented Feb 8, 2020

I suspect this isn't because the scripts are executed in the wrong order, but because:

  1. Form Builder's Scala.js code uses Dragula, so we have code using Dragula in 1. baseline. I checked this in the source.
  2. But the Dragula's JavaScript is only indirectly imported by XBL components, and so the Dragula code ends up in 2. additional. I checked this in the source.
  3. I suspect that in some cases code in 1. baseline runs before 2. additional is loaded (maybe something is ready in the DOM before 2. additional is loaded), and that code can't find Dragula. Only a suspicion: I haven't checked this by debugging the code.

Anyhow, if Form Builder depends on Dragula, that decency should be explicit, for now adding it to oxf.xforms.assets.baseline.updates.fb, and we shouldn't rely Dragula being loaded because Form Builder also uses some XBL controls that use Dragula. So as a tentative fix I added Dragula to oxf.xforms.assets.baseline.updates.fb, and I don't seem to be able to reproduce the problem anymore.

Maybe we can share a build with the customer from their 2019.2 PE branch so they can check if that also resolves the problem for them.

  • Move Dragula out of the tabbable XBL directory, since it is also used by dnd-repeat.xbl and Form Builder
@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

@ebruchez ebruchez commented Feb 8, 2020

Regarding the facades, I have some local changes to move them to a separate subproject.

avernet added a commit that referenced this issue Feb 10, 2020
@avernet avernet assigned avernet and unassigned ebruchez Feb 10, 2020
@avernet avernet moved this from To review to Done in Orbeon Forms 2020.1 Feb 10, 2020
@avernet avernet closed this Feb 10, 2020
@ebruchez

This comment has been minimized.

Copy link
Collaborator Author

@ebruchez ebruchez commented Feb 10, 2020

For the facades, see b65a959 and 555054b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.