nrkno / sofie-timeline-state-resolver

Sofie Timeline State Resolver: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
14 stars 20 forks source link

Bug Report: error with video format in CasparCG integration #326

Closed PascalViauRC closed 5 months ago

PascalViauRC commented 5 months ago

About me

This RFC is posted on behalf of CBC/Radio-Canada.

Observed Behavior

When trying to connect to CasparCG, a weird error message appears and the connection fails. The error message looks like this :

{"0":"T","1":"y","2":"p","3":"e","4":"E","5":"r","6":"r","7":"o","8":"r","9":":","10":" ","11":"o","12":"b","13":"j","14":".","15":"f","16":"o","17":"r","18":"m","19":"a","20":"t","21":".","22":"t","23":"o","24":"U","25":"p","26":"p","27":"e","28":"r","29":"C","30":"a","31":"s","32":"e","33":" ","34":"i","35":"s","36":" ","37":"n","38":"o","39":"t","40":" ","41":"a","42":" ","43":"f","44":"u","45":"n","46":"c","47":"t","48":"i","49":"o","50":"n","51":"\n","52":" ","53":" ","54":" ","55":" ","56":"a","57":"t","58":" ","59":"/","60":"h","61":"o","62":"m","63":"e","64":"/","65":"S","66":"o","67":"f","68":"i","69":"e","70":"/","71":"D","72":"o","73":"c","74":"u","75":"m","76":"e","77":"n","78":"t","79":"s","80":"/","81":"S","82":"o","83":"f","84":"i","85":"e","86":"/","87":"s","88":"o","89":"f","90":"i","91":"e","92":"...

After a while, I was able to "decode" the error message by assembling the letters by index. So "0":""T" is T, "1":"y" is y, and so on. The decoded message is now : TypeError obj.format.toUpperCase is not a function\n at /home/Sofie/Documents/Sofie/sofie-core/packages/node_modules/timeline-state-resolver/dist/integrations/casparCG/index.js12343\n ...

Expected Behavior

In this part of casparCG/index :

this._currentState.channels[obj.channel] = {
    channelNo: obj.channel,
    videoMode: obj.format.toUpperCase(),
    fps: obj.frameRate,
    layers: {},
}

the obj.format I get from the response is a number and not a string (obj.format = 1080 instead of "1080" or "1080p2997"), causing toUpperCase() to crash.

I don't know if I have a problem with my CasparCG server config and I'm not using the latest version, but it would be a good idea to convert obj.format to a string to avoid the issue :

this._currentState.channels[obj.channel] = {
    channelNo: obj.channel,
    videoMode: String(obj.format).toUpperCase(),
    fps: obj.frameRate,
    layers: {},
}

Doing this worked for me. And as for the error message, I don't know why it's "indexified" like that, but it's a nice puzzle to solve...😅

Version

Sofie core 1.49.3, timeline-state-resolver 8.1.2

Severity / Impact

We fixed the issue locally so it's not an urgent problem.

nytamin commented 5 months ago

Thanks for your bug report, @PascalViauRC !

Yes, the wierd logging is something we should look into, thanks for bringing it up!

Regarding the obj.format issue; I'm pretty certain this bug stems from the casparcg-connection library outputting something it shouldn't. I'd really like to understand what might have gone wrong.

Would you mind checking a few things for me?

  1. Which CasparCG version are you running?
  2. In the CasparCG terminal, type INFO (and hit enter). What is the exact output?
  3. In TSR, do you still have the same issue if you update the casparcg-connection to latest version (6.2.1)?
PascalViauRC commented 5 months ago

Thanks @nytamin!

Here is the INFO output :

INFO
[2024-04-03 10:23:14.825] [info]    Received message from Console: INFO\r\n
#200 INFO OK
1 1080p2997 PLAYING
2 1080p2997 PLAYING
3 1080p2997 PLAYING
4 1080p2997 PLAYING
5 1080p2997 PLAYING

[2024-04-03 10:23:14.826] [debug]   Executing command: INFO
[2024-04-03 10:23:14.839] [debug]   Executed command (0.013s): INFO

I'm already using casparcg-connection 6.2.1.

nytamin commented 5 months ago

Thanks! I really don't understand what might have gone wrong, ~but I'll add a String() guard in TSR to be extra safe~ since this code has changed in the release51-branch of TSR and no longer does a toUpperCase I think I'll leave it be.