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

initializing with video js options is not working #121

Open
axten opened this issue May 28, 2018 · 7 comments
Open

initializing with video js options is not working #121

axten opened this issue May 28, 2018 · 7 comments

Comments

@axten
Copy link
Contributor

axten commented May 28, 2018

Description

plugin initializing with video js options is not working.

Steps to reproduce

just do:

import videojs from 'video.js';
import 'videojs-errors';

const options = {
    plugins: {
        errors: { 
            errors: {
                FOO: {
                    headline: 'headline',
                    message: 'This is a custom error message'
                }
            }
        }
    }
};

const player = videojs(element, options, () => {

    setTimeout(() => {
        console.log(player.errors.getAll()); // contains FOO error

        player.error({code: 'FOO'}); // empty error screen appears
        
    },2000);
});


Results

Expected

custom error should be visible

Actual

error screen appears empty (except a white X)

Error output

Additional Information

videojs

6.8

errors plugin

4.1

@axten
Copy link
Contributor Author

axten commented Jun 4, 2018

I digged deeper and found out that the error content html is build properly. something went wrong after using fillWithmethod of the dialog:

https://github.com/brightcove/videojs-errors/blob/ee400679cde77971117bc0aab1ad50866c010d98/src/plugin.js#L271

seams to be a race condition with:
https://github.com/videojs/video.js/blob/2da7af1137e3c8f3b14bd603f17fef3173fe2da0/src/js/modal-dialog.js#L183

so errors plugin fills the dialog and dialog refills it on open with empty content o_0
@gkatsev any ideas how to fix that?

@axten
Copy link
Contributor Author

axten commented Jun 4, 2018

https://github.com/brightcove/videojs-errors/blob/ee400679cde77971117bc0aab1ad50866c010d98/src/plugin.js#L240

adding display.options_.fillAlways = false; after that line fixed the race condition.
but a bit hacky...

@gkatsev
Copy link
Member

gkatsev commented Jun 4, 2018

this may be that videojs-errors expects the player to be created when it is initialized and so initializing it via options is too early for it. We probably should guard against that.

@axten
Copy link
Contributor Author

axten commented Jun 4, 2018

So now I'm sure that it's a race condition between the error event handlers:
https://github.com/videojs/video.js/blob/2da7af1137e3c8f3b14bd603f17fef3173fe2da0/src/js/error-display.js#L27
https://github.com/brightcove/videojs-errors/blob/ee400679cde77971117bc0aab1ad50866c010d98/src/plugin.js#L320

They simply change order when errrors-plugin is invoked later by player.errors().
In this case, the error does not occure:

  1. error-display#on('error') calls-> open() calls-> fill() <-- then it is empty
  2. errors-plugin#on('error') calls -> fillWith()

but with options init, these handlers change order and the custom error modal gets overriden.

@axten
Copy link
Contributor Author

axten commented Jul 9, 2018

ping @gkatsev

@axten
Copy link
Contributor Author

axten commented Jan 10, 2019

any plans to fix this?

@jomarquez21
Copy link

some update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants