1

In a managed package, I have lwc with combobox whose options are fields from an object. It calls an apex method that returns the list of fields and then displays them.

I have noticed for specific customer org that the loading time for the combo-box taking way too long. The delay time happens in two events: 1.When loading the options in the combobox 2.When selecting a specific value

Naturally, the list of values depends on the number of fields in the object; however, in other orgs I used an object with 800 fields and didn't notice any issues. It also seems that the delay in event 2, indicates that the issue is not on the server.

I saw several posts on the performance issue for combobox, related to locker service, but still was not able to reproduce it in any other orgs.

Does anyone have experience with a similar issue and can suggest how to tackle it? Are there any org global settings that might affect this behaviour?

update I discovered that the following option affect the performance:

"Use Lightning Web Security for Lightning web components and Aura components"

When it is set to off the performance is poor. Is there any good way to solve it without switching the option to on?

1 Answer 1

1

Locker Service is painfully slow, especially when dealing with large arrays. See my earlier example. This is because an array passed through an attribute is filtered each time you access an individual element; 800 elements results in a total of 640,800 array accesses (800 array copy operations and individual filtering), plus lots of memory thrashing. With Lightning Web Security (LWS), this doesn't happen, because security is enforced in a far simpler manner. For your own components, you can mitigate this by copying the array first, as demonstrated in my answer. However, built-in components don't have the option of modifying. So, your two basic options are to either (a) implement a custom combobox component, or (b) enable LWS.

1
  • Thanks for the explanation. The difference in performance is indeed huge. Since most are running the LWS, I think I'll leave it this way for now.
    – Liron C
    Dec 12, 2023 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .