videojs / video.js

Video.js - open source HTML5 video player
https://videojs.com
Other
37.59k stars 7.4k forks source link

TypeError: Cannot read property 'currentTime' of null #7730

Open KVPasupuleti opened 2 years ago

KVPasupuleti commented 2 years ago

Description

We are catching the errors/exceptions in Sentry. We often get these exceptions

TypeError: Cannot read property 'currentTime' of null
  at currentTime(../node_modules/video.js/dist/video.es.js:21454:17)
  at done(../node_modules/video.js/dist/video.es.js:50891:50)
  at doneFn(../node_modules/video.js/dist/video.es.js:44383:9)
  at apply(../node_modules/video.js/dist/video.es.js:46525:9)
  at SourceBuffer.r(../../src/helpers.ts:87:17)
TypeError: Cannot read properties of null (reading 'paused')
  at method(../node_modules/video.js/dist/video.es.js:21454:17)
  at get(../node_modules/video.js/dist/video.es.js:9871:66)
  at techGet_(../node_modules/video.js/dist/video.es.js:23999:14)
  at paused(../node_modules/video.js/dist/video.es.js:24162:17)
  at apply(../node_modules/videojs-landscape-fullscreen/dist/videojs-landscape-fullscreen.es.js:69:18)
  at r(../../src/helpers.ts:87:17)

Steps to reproduce

Not sure about the steps to reproduce, I guess it's happening because the player is being accessed after it's unmounted. I am sure we are disposing the player using this.videoPlayer.dispose() in componentWillUnmount of React

Results

Expected

These issues should not be reported

Actual

These issues are reported

Error output

Not getting any error in the UI, but these are not thrown in the console

Additional Information

Please include any additional information necessary here. Including the following:

versions

videojs 7.14.3

what version of videojs does this occur with?

browsers

what browser are affected?

Chrome, Firefox

what platforms (operating systems and devices) are affected?

Windows 10, Andriod 10

are any videojs plugins being used on the page? If so, please list them below.

These are not causing any UI issues or crashes, but I am curious why these are happening and if there is something we can do to get rid of these.

gkatsev commented 2 years ago

Based on the stack trace snippet, it seems like the issue comes from videojs-landscape-fullscreen. There's likely some event handler that sticks around and isn't getting removed on dispose.

Looking at the code, it seems like they're adding an orientationchange event handler but then aren't doing player null checks or removing the handler when the player is disposed: https://github.com/prateekrastogi/videojs-landscape-fullscreen/blob/master/src/plugin.js#L80

KVPasupuleti commented 2 years ago

Yeah, got it. Will try raising a PR to videojs-landscape-fullscreen and if the folks there won't respond, will try to handle it in my code.

And what about the currentTime exception? (Sorry, I have written same stack trace for both the issues. Edited now)

gkatsev commented 2 years ago

Looks like the source updated in VHS still updated? at apply(../node_modules/video.js/dist/video.es.js:46525:9) corresponds to https://github.com/videojs/http-streaming/blob/80138302483c3e0a9cdfab6d878d24d848f4f8c8/src/source-updater.js#L312

What does your helpers.ts line 87 do?

KVPasupuleti commented 2 years ago

I have raised a PR for videojs-landscape-fullscreen.

I don't think this is funny, but what is he actually saying?

It's supposed to be nested and I feel that's irrelevant for the issue happened.

And, it seems it's the TypeError misleading the context there.

KVPasupuleti commented 2 years ago

Looks like the source updated in VHS still updated? at apply(../node_modules/video.js/dist/video.es.js:46525:9) corresponds to https://github.com/videojs/http-streaming/blob/80138302483c3e0a9cdfab6d878d24d848f4f8c8/src/source-updater.js#L312

What does your helpers.ts line 87 do?

And regarding this, I think helpers.ts could probably be supplied by create-react-app with typescript under the hood.

Not sure what it's actually doing, but I think it's just a wrapper.

gkatsev commented 2 years ago

Not sure what the responses in videojs-landscape-fullscreen are about.