Figma.notify and figma.ui.postMessage do not work in background

I am trying to traverse the trees in the document pages and find the text layers. It takes some time to execute the task on huge documents, so I do not want the clients to experience the long waiting and think that the plugin is stuck. My thought was to show which Pages and their children are currently being processed, and to send instantly the messages to UI part via figma.ui.postMessage, but I was out of luck. It seems like the process is blocking the main Thread and it queues these messages to send them after the process is finished. I thought of also maybe using figma.notify function to notify the user by showing a message via Figma, but it works in the same way. I pretty understand that changing the document in another thread and sending messages from iframe to main thread is not good idea, but I do not see any problems to notify the UI immediately every time I call figma.ui.postMessage. But, I may be wrong, but seems like Figma and iframe’d plugins work on the same main Thread and that is why I even cannot close the plugin while calling the findAll, findOne methods or even iterating over the PageNode children

1 Like

I’m having the same problem. I built a plugin to dynamically create a table (the user enters the number of columns, rows and some other settings), but depending on the size of the table, it may take a while to generate it. I tried figma.ui.postMessage to update a progress bar on my iFrame and when that didn’t work I tried figma.notify. I know this is a 2 year old thread, but did you find a workaround @David_Baum?

1 Like
1 Like

Oh fantastic, it worked like a charm! Thanks @tank666