Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]-Verify all devices implementing IUsageTracking initializes usage tracker #1174

Open
jkdevito opened this issue Feb 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jkdevito
Copy link
Contributor

jkdevito commented Feb 6, 2024

Was this bug identified in a specific build version?
Essentials 1.16.0-rc-2374

Describe the bug
Attempting to invoke UsageTracker.StartDeviceUsage() on a source with "type": "laptop" will cause a null exception.

Stacktrace

Include a stack trace of the exception if possible.

Error: SimplSharpPro.exe [App 1] # 2024-02-06 12:50:22  # Exception:BeginInvoke- Unhandled exception: - System.NullReferenceException: NullReferenceException
   at PepperDash.Essentials.Plugin.Room.RoomController.<>c__DisplayClass18.<RunRouteAction>b__17(Object o)
   at Crestron.SimplSharp.UserThreadStartDeleg 12. Error: SimplSharpPro.exe [App 1] # 2024-02-06 12:50:22  # ateWrapper.a(Object A_0)
   at System.Threading.Timer.ring()

To Reproduce
Steps to reproduce the behavior:

  1. Load system using Essentials Room (or api-room) with a source using the configuration:
{
    "key": "laptop-1",
    "name": "HDMI 1",
    "type": "laptop",
    "group": "pc",
    "uid": 7,
    "id": "24db1d75-9444-45e0-b105-0fdf422dcbef",
    "properties": {
        "isDefault": false
    }
}
  1. Routing the source using the RunRouteAction method will attempt to start the device usage tracker, causing the null reference exception.

Additional context
Added a null reference check on the UsageTracker to RunRouteAction to prevent the exception:

// Start usage timer on routed source
if (sourceListItem.SourceDevice is IUsageTracking && (sourceListItem.SourceDevice as IUsageTracking).UsageTracker != null)
{
    (sourceListItem.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage();
}
@jkdevito jkdevito added the bug Something isn't working label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant