potmat / homebridge-google-nest-sdm

A Homebridge plugin for Google Nest devices that uses the Google Smart Device Management API. Supports Cameras, Doorbells, Displays, and Thermostats. Includes support for HomeKit Secure Video.
ISC License
140 stars 17 forks source link

Second Gen Google Cameras throw a RangeError when attempting to view stream #92

Closed chris-aslett closed 1 year ago

chris-aslett commented 1 year ago

When I try to view the video stream of a second gen camera in the Home app I get a "No Response" error and the Homebridge console displays RangeError: offset is out of bounds (first gen cameras are able to stream just fine):

[09/08/2023, 14:40:32] [homebridge-google-nest-sdm] RangeError: offset is out of bounds
    at Uint8Array.set (<anonymous>)
    at Function.padStart (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/webcrypto-core/build/webcrypto-core.js:972:13)
    at Function.encodeSignature (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/webcrypto-core/build/webcrypto-core.js:940:22)
    at Function.sign (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/@peculiar/webcrypto/build/webcrypto.js:1575:54)
    at EcdsaProvider.onSign (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/@peculiar/webcrypto/build/webcrypto.js:1737:25)
    at EcdsaProvider.sign (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/webcrypto-core/build/webcrypto-core.js:157:28)
    at SubtleCrypto.sign (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/webcrypto-core/build/webcrypto-core.js:1405:39)
    at Function.create (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/@peculiar/x509/build/x509.cjs.js:2407:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Function.CipherContext.createSelfSignedCertificateWithKey (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/dtls/src/context/cipher.ts:111:18)
    at RTCDtlsTransport.setupCertificate (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/werift/src/transport/dtls.ts:69:9)
    at RTCPeerConnection.createOffer (/usr/local/lib/node_modules/homebridge-google-nest-sdm/node_modules/werift/src/peerConnection.ts:221:7)
    at WebRtcNestStreamer.initialize (/usr/local/lib/node_modules/homebridge-google-nest-sdm/src/NestStreamer.ts:104:21)
    at CameraStreamingDelegate.startStream (/usr/local/lib/node_modules/homebridge-google-nest-sdm/src/StreamingDelegate.ts:300:20)
potmat commented 1 year ago

That's a strange one, somewhat similar to: https://github.com/potmat/homebridge-google-nest-sdm/issues/68

Maybe try what he did...

chris-aslett commented 1 year ago

Thanks for the quick reply! I created a child bridge and added the new bridge to the Home app but the result is the same. Gen 2 cameras throw the RangeError and Gen 1 cameras stream fine.

I'm running:

potmat commented 1 year ago

What happens if you try Node 16?

dgreif commented 1 year ago

@potmat a very similar error popped up on the homebridge-ring plugin in the last week or so, we haven't found a solution yet, but I'm guessing we're both facing the same bug, whatever it may be 😄.

potmat commented 1 year ago

@dgreif: That's very helpful, thanks for sharing! Definitely a transitive dependency that is not version locked, looks like related to certificate parsing.

dgreif commented 1 year ago

Yep. One idea on the Ring side is that it could be related to iOS 17 beta. @chris-aslett which version of iOS are you currently using?

potmat commented 1 year ago

@dgreif: I don't think that's the case. The error is happening when Homebridge is trying to connect to the WebRTC stream provided by Google. iOS is not even involved at that stage.

chris-aslett commented 1 year ago

Yep. One idea on the Ring side is that it could be related to iOS 17 beta. @chris-aslett which version of iOS are you currently using?

@dgreif: I’m accessing from iPhone running 16.6, an iPad running 16.6, and a ATV running 17 beta.

chris-aslett commented 1 year ago

What happens if you try Node 16?

@potmat, same error with 16.20.2!

tsightler commented 1 year ago

Looks like this is likely caused by pvtsutils v1.3.3, which was pushed 8 days ago. There is already a similar issue reported at https://github.com/PeculiarVentures/pvtsutils/issues/12.

We see the same issue in homebridge-ring/ring-client-api, which uses werift 0.18.5, and thus has the same dependency. I have verified that updating my pvtsutils to 1.3.3 breaks with the same error and reverting to 1.3.2 fixes is.

potmat commented 1 year ago

Thank you @tsightler!

potmat commented 1 year ago

@chris-aslett, try version 1.1.15, you may need to uninstall and reinstall the plugin

adamneveu commented 1 year ago

Sorry - just clarifying here - does this plugin work with Nest app only supported doorbells or also the new Gen2 Battery?

potmat commented 1 year ago

@adamneveu: It should work with the Gen2 battery just fine.

chris-aslett commented 1 year ago

@chris-aslett, try version 1.1.15, you may need to uninstall and reinstall the plugin

@potmat: v1.1.15 worked great, thank you!