videojs-errors icon indicating copy to clipboard operation
videojs-errors copied to clipboard

initializing with video js options is not working

Open axten opened this issue 7 years ago • 7 comments

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 avatar May 28 '18 12:05 axten

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 avatar Jun 04 '18 10:06 axten

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...

axten avatar Jun 04 '18 12:06 axten

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.

gkatsev avatar Jun 04 '18 16:06 gkatsev

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 avatar Jun 04 '18 20:06 axten

ping @gkatsev

axten avatar Jul 09 '18 20:07 axten

any plans to fix this?

axten avatar Jan 10 '19 08:01 axten

some update?

jomarquez21 avatar Apr 19 '21 18:04 jomarquez21