openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

v2.ODataModel requires datajs synchronously if created with `preload: true`

Open boghyon opened this issue 4 years ago • 4 comments

Open https://embed.plnkr.co/nxTR3eO9kNZo42CR?show=Component.js,preview. It has data-sap-ui-xx-nosync="true" enabled as well as preload: true in manifest.json.

The model should be created successfully but fails since sap/ui/thirdparty/datajs.js is apparently fetched synchronously in the above case despite enabling async features everywhere when possible.

  • Loading sap/ui/model/odata/v2/ODataModel.js isolated shows no sync XHR problem: https://jsbin.com/lawatow/edit?html,js,output
  • The issue remains even after creating Component-preload.js via tooling.

I didn't test other cases but I assume models, in general, that have dependency to third-party module(s) are affected, not only the v2.ODataModel.

App developers would then need to either disable the preload: true setting in manifest.json, or add sap/ui/thirdparty/<lib> to the sap-ui-modules config.

boghyon avatar Jan 27 '21 17:01 boghyon

That's a consequence of the sync loading of model implementations when preloading models during component loading. We have conflicting goals here: not to (further) bloat the sap.ui.core preload with bigger thirdparty files. That's why we omitted many thirdparty files from the preload when their usage is not guaranteed (jquery, jquery mobile, hasher, signal and crossroads are exceptions as they are used in nearly all apps). datajs was left out as it is only needed for OData V2. On the other side, preloading shall allow early requests for the OData v2 metadata files.

To be honest, the preload mechanism was initially only designed for the FLP scenario and there we have a custom bootstrap including datajs, so it doesn't matter.

We should discuss this and see what can be done. For async component loading, we should be able to asynchronously require the model implementations, but currently, there's no such path, AFAIK.

codeworrior avatar Jan 27 '21 18:01 codeworrior

Hello @boghyon Thank you for sharing this finding. I've created an internal incident 2180065338. The status of the issue will be updated here in GitHub. Regards, @kskondov

kskondov avatar Jan 29 '21 16:01 kskondov

@codeworrior you're right there is not path for this scenario... which suprised by a bit to be honest... I created a backlog item for this and informed the PO: CPOUI5FRAMEWORK-210

Thodd avatar Feb 02 '21 10:02 Thodd

It's kinda related: https://github.com/SAP/openui5/issues/3193

mauriciolauffer avatar Nov 09 '21 21:11 mauriciolauffer

For future readers..:

Open https://embed.plnkr.co/nxTR3eO9kNZo42CR?show=Component.js,preview. It has data-sap-ui-xx-nosync="true" enabled [...]

The sap-ui-xx-nosync option is no longer usable after the change https://github.com/SAP/openui5/commit/86caa923daa73e12a0fa107b4c9609e276e5b443 --> Fixed with b774db7

But the relevant requireSync call is still there: https://github.com/SAP/openui5/blob/0688cce81d90e624351dacadff67aef772343aeb/src/sap.ui.core/src/sap/ui/core/Component.js#L2059

boghyon avatar Oct 18 '23 15:10 boghyon

any plans to remove requireSync and make it fully async?

mauriciolauffer avatar Oct 18 '23 23:10 mauriciolauffer

The sap-ui-xx-nosync issue should be fixed with b774db74262d1af1a749b2b23b557557622eecd7.

@mauriciolauffer: all synchronous JS loading paths are deprecated and will be removed with UI5 2.0. The backlog item CPOUI5FRAMEWORK-210 is currently planned and will take care of the sync loading specific to datajs.

Thodd avatar Oct 19 '23 07:10 Thodd

With https://github.com/SAP/openui5/commit/337b1768cff287cf22c3fbfe4458afd66795c894, this issue can be closed. Thanks @Thodd!

boghyon avatar Nov 02 '23 10:11 boghyon