Skip to content

Excessive Calls to OnNewTrigger/OnInstantiateTrigger for AbstractTriggerType and AbstractTriggerType2 #364

@hem-bhagat-tark

Description

@hem-bhagat-tark

Environment

HomeSeer

OS

Windows

HS Version

v4.2.21.0

Development

PSDK Version

v1.4.3.0, v1.4.4.0 and v1.5.0.0

Language

C#

IDE

VS2022

Dev OS

Windows

Problem

Excessive Calls to OnNewTrigger/OnInstantiateTrigger for AbstractTriggerType and AbstractTriggerType2

Description

I've observed a strange and potentially problematic behavior with AbstractTriggerType and AbstractTriggerType2. The OnNewTrigger and OnInstantiateTrigger methods are being called an unusually high number of times during plugin initialization and when interacting with the Events page—for example, when configuring or viewing event actions.

To find number of calls at the time of plugin initialization, I logged the number of times OnInstantiateTrigger was invoked and consistently found it being called 844 times, regardless of how many times I restarted. This number appear to correlate with the number of devices + features in my system which is also 844.

For AbstractTriggerType, this excessive invocation only seems to occur when the trigger’s ConfigPage does not include any input elements. Or at least that is what I can deduce because, I had a ConfigPage with only a LabelView and the excessive invocation was consistent. However, as soon as I added an InputView, the excessive invocation stopped. With AbstractTriggerType2, the problem occurs unconditionally, regardless of the content in the config page.

To rule out interference from other parts of my plugin, I created a minimal version that includes only the trigger definitions, and the issue still persists. This behavior is particularly problematic for AbstractTriggerType2 because it requires rendering the entire configuration page with each call to OnInstantiateTrigger, which involves making multiple DB and HomeSeerSystem calls. As a result, the repeated calls introduce significant overhead and make AbstractTriggerType2 difficult to use in practical scenarios.

While I’ve also noticed a similar pattern with AbstractActionType, I haven’t explored it in detail yet, so this report focuses specifically on the triggers. Based on these findings, I believe this is likely a bug and would appreciate it if the team could investigate further.

Screenshots

AbstractTriggerType - With only LabelView

Image

Image

AbstractTriggerType - With an InputView

Image

Image

AbstractTriggerType2

Image

Image

Device Count

Image

Expected Behavior

The methods should not be called soo many times.

Steps to Reproduce

  1. Create a fresh plugin with two triggers, one which implements AbstractTriggerType and one which implements AbstractTriggerType2. In the ConfigPage of triggers keep only a LabelView with simple text.
  2. Start remote debugging for the plugin, go the Events page and create two events using each of the triggers.
  3. Once configured, add debugger or a console log to the AbstractTriggerType's OnNewTrigger method and AbstractTriggerType2's OnInstantiateTrigger method.
  4. Restart the remote debugging for the plugin and you will see the debugger will hit continuously or many console logs being printed for both the triggers.
  5. Now, deleted the configured events and remove the debugger/console log. Instead of having a simple LabelView in the ConfigPage, add an InputView to the ConfigPage for both of the Triggers.
  6. Restart remote debugging for the plugin to reflect the changes, again configure two events as done previously and add debugger/console log as per previous steps.
  7. Restart remote debugging again. You will see that the debugger will not hit/console log will not be printed for AbstractTriggerType but for the AbstractTriggerType2 it will same behavior as previous one.

Logs

Not Applicable

Metadata

Metadata

Assignees

No one assigned

    Labels

    App MisbehaviorThis problem is causing HomeSeer to not do what was expected. NOT FOR PLUGINSHS CoreThis issue involves changes to core HS systems. NOT FOR PLUGINSTo DoThis issue is in need of attention

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions