Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
107 stars 83 forks source link

SDKDOMInstance fails to instanciate #6315

Closed Psychokiller1888 closed 1 year ago

Psychokiller1888 commented 1 year ago

Problem description

CreateElement fails with a JS error

Attach a .c3p

Try this plugin and run any empty project https://github.com/AirConsole/airconsole-construct3/blob/1.8.0.0/airconsole.c3addon

Steps to reproduce

  1. Load the plugin
  2. Run preview
  3. Check console

Observed result

sdkDOMInstanceBase.js:4
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'IsVisible')
at AirConsoleInstance.CreateElement (sdkDOMInstanceBase.js:4:247)
at new AirConsoleInstance (5502d4cd-5abc-4cc4-a5ee-e6a1d7085cf1:25:8)
at C3.New (jsutil.js:15:47)
at Instance._CreateSdkInstance (instance.js:7:189)
at ObjectClass._CreateSingleGlobalInstance (objectClass.js:13:454)
at new ObjectClass (objectClass.js:8:314)
at C3.New (jsutil.js:15:47)
at ObjectClass.Create (objectClass.js:8:404)
at C3Runtime._LoadDataJson (runtime.js:30:342)
at C3Runtime.Init (runtime.js:21:462)

Expected result

Well, at least an explanation of what is awaited.... What should be visible? Thee docs don't mention anything about this

More details

Affected browsers/platforms:

First affected release: No idea, first time using SDKDOMInstance

System details

View details ``` sdkDOMInstanceBase.js:4 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'IsVisible') at AirConsoleInstance.CreateElement (sdkDOMInstanceBase.js:4:247) at new AirConsoleInstance (5502d4cd-5abc-4cc4-a5ee-e6a1d7085cf1:25:8) at C3.New (jsutil.js:15:47) at Instance._CreateSdkInstance (instance.js:7:189) at ObjectClass._CreateSingleGlobalInstance (objectClass.js:13:454) at new ObjectClass (objectClass.js:8:314) at C3.New (jsutil.js:15:47) at ObjectClass.Create (objectClass.js:8:404) at C3Runtime._LoadDataJson (runtime.js:30:342) at C3Runtime.Init (runtime.js:21:462) ```
AshleyScirra commented 1 year ago

The plugin has a weird configuration. It pretends to be a HTML element, like a button or text input, but it's clearly not that as it's also a single-global plugin that only has one instance in the project and does not have any position or size (which all HTML elements do have).

I tried fixing the initial error, but then another error happened instead, also relating to the fact Construct is trying to use it as a HTML element. I can only conclude the plugin is misconfigured - the addon developer will need to fix it.

Psychokiller1888 commented 1 year ago

Yes, and that's the question... How do you have a single global plugin be able to communicate to the dom side that is using an API....

AshleyScirra commented 1 year ago

There's a domMessagingPlugin sample in the addon SDK download. Any plugin can use DOM messaging methods to communicate with a DOM-side script. There is no need to try to pretend the plugin is a HTML element.