Unresponsive bug when working with interactions and components are used

Hi,

I have a piece of code in my plugin that extracts all interactions from a document.
I am using ‘interactions.allInteractions’ to get a list of interactions I can iterate over.

It is working as expected, until I add a component to my an artboard and add an interaction to it. A basic simple interaction like tap and gotoartboard is enough to make it break.

Simplest case is to spin up simple plugin template, and add console.log(interactions.allInteractions). That will make the plugin unresponsive, if a component with an interaction is added.

Specifically; I loop this array, but as soon as a I access an item eg. interactions.allInteractions[0] and that item is an interaction on a component, the code just freezes. Accessing other elements that is not an interaction on a component works with no freezing.

EDIT: It appears that this is also a problem when accessing Artboard.incomingInteractions and a component links to that artboard. Also if the component is in the library only and not in the document.

Hope for a quick solution.

@DavidXD ^^^ Any ideas here?

Hi, Sebbe. I spent some time looking at this with my interactions test plugin, and was unable to reproduce this problem with components. I tried on both Mac and Windows. If you could please provide some more information, I will investigate further.

  • Specific version of XD
  • Mac or Windows?
  • Example XD document that causes the bug (you can upload here)
  • Snippet of the plugin code that fails

Hi @DavidXD

I have investigated a bit further, and found that it was not a problem with interactions.allInteractions after all. Sorry about that.

But I still got a problem related to it.
I’m on Windows 10 with XD version 36.2.32.5

For each interaction I am trying to locate what artboard the triggerNode is in (Please advice if there is a better way). I do that with a small recursive function to find the parent Artboard. If I do this on nodes in the pasteboard or Components in the Library the parent property is breaking my code.

function getParentArtboard(node) {
	
  if (node instanceof Artboard) return node;

  return getParentArtboard(node.parent);
}

function runCommand() {

    const indexedInteractions = interactions.allInteractions;

    for (let i = 0; i < indexedInteractions.length; i++) {
        const node = indexedInteractions[i].triggerNode;
        const artboard = getParentArtboard(node);
        console.log(indexedInteractions[i].triggerNode.name, "is in", artboard ? artboard.name : "no artboard");
    }
}

I have created a small sample XD document along with my test plugin source:

xd-example-bug.zip (15.2 KB)

Thank you!

To elaborate, I’m also seeing this error message:

Plugin TypeError: Cannot read property ‘8d407748::develop’ of undefined
at $Root.Group.pluginWrapper (lib/scenegraph/GroupExtension.js:1:25201)
at SymbolInstance.get (plugins/ScenegraphWrappers.js:1:13561)
at getParentArtboard (\develop\8d407748\main.js:24:12)
at e.exports.triggerBugFunction (\develop\8d407748\main.js:11:24)
at Object._dispatchCommandIdEvent (uxp://uxp-internal/pluginmanager_scripts.js:1:41491)
at Object.invokeCommand (uxp://uxp-internal/pluginmanager_scripts.js:1:40854)
at N.invokeCommand (uxp://uxp-internal/pluginmanager_scripts.js:1:19468)
at plugins/PluginLoader.js:1:5941
at Object.execScenegraphEdit (plugins/ScenegraphGuard.js:1:5317)
at BaseCommand._invokePluginCommand [as _commandFn] (plugins/PluginLoader.js:1:5892)
at BaseCommand.execute (lib/BaseCommand.js:1:929)
at Object.D [as executePluginCommand] (uxpDocumentUI/js/10.js:18:17410)
at e.exports._uiEntry.panelId._uiEntry.commandId.n.onclick (uxpDocumentUI/js/10.js:18:31844)
at e.exports.p (uxp://uxp-internal/domjs_scripts.js:2:24351)
at uxp://uxp-internal/domjs_scripts.js:2:8303
at Object.runWithNativeHandler ()
at I (uxp://uxp-internal/domjs_scripts.js:2:8195)
at uxp://uxp-internal/domjs_scripts.js:2:7803
at O (uxp://uxp-internal/domjs_scripts.js:2:7814)
at k (uxp://uxp-internal/domjs_scripts.js:2:8472)
at e (uxp://uxp-internal/domjs_scripts.js:2:8970)
at e.exports.onEvent (uxp://uxp-internal/domjs_scripts.js:2:186448)

Line 24 in main.js is where I access node.parent of the component in the library
24: return getParentArtboard(node.parent);

Also updated to latest version of XD: 37.0.32.10

Sebbe, thank you for the code and detailed information. I was able to reproduce the error you saw when trying to get the parent of an interaction trigger node when that node is a component. I logged a bug with our team.

1 Like

Thank you @DavidXD
Hoping for a quick fix.

Is there anythink I can do to detect if the triggerNode is in a component or not? The bug is breaking my plugin at the moment.

Thank you!

Here is some code to determine if a node is a Component:

if (node.constructor.name === "SymbolInstance") { ...

1 Like

I can confirm that adding this check works.

I have just submitted my plugin with the fix. Thank you!

1 Like