Skip to main content

Hi,

Running into an issue where findAllWithCriteria suddenly gets a magnitude slower than it normally is/Closing the file and re-opening it or restarting Figma resolves the issue for a while until it happens again

Here’s the sample code:

const start = Date.now();
const n = frame.findAllWithCriteria({
sharedPluginData: {
namespace: annotationNamespace,
keys: :annotationKey],
},
});
console.log('result', n.length, Date.now() - start, figma.skipInvisibleInstanceChildren);

Here’s the output when it works normally:

result 28 0 true
result 364 3 true
result 57 1 true

And this is the output after it starts to happen from my console.log:

result 28 18 true
result 364 1678 true
result 57 179 true

As you can see it goes from 0-3ms to 18ms - 1700ms, almost ~1000x the expected time.

The issue is relatively rare and I haven’t found any specific patterns that triggers it. It’s not related to the skipInvisibleInstanceChildren flag but seems to be more common in larger files and when doing a lot of changes.

Closing other applications or tabs in Figma to free up memory doesn’t seem to help, restarting the plugin doesn’t help either, only closing and re-opening the file with the issue fixes it.

Is this a bug in Figma and has anyone else run into anything similar?

Be the first to reply!

Reply