瀏覽代碼

fix(GUM-permissions): cache permissions on init.

Not upadting the permissions from the Permissions API call on init is
causing the permissions cache to be filled from GUM resolve/reject logic
only when there aren't any permissions updates. This  may
lead to unknown permission status when we can report  the correct
status from the initial permission API request.
dev1
Hristo Terezov 4 年之前
父節點
當前提交
d1f0ab4d5a
共有 1 個檔案被更改,包括 6 行新增8 行删除
  1. 6
    8
      JitsiMediaDevices.js

+ 6
- 8
JitsiMediaDevices.js 查看文件

43
 
43
 
44
         // Test if the W3C Permissions API is implemented and the 'camera' and 'microphone' permissions are
44
         // Test if the W3C Permissions API is implemented and the 'camera' and 'microphone' permissions are
45
         // implemented. If supported add onchange listeners.
45
         // implemented. If supported add onchange listeners.
46
-        //
47
-        // NOTE: We don't cache the result for the query because this can potentialy lead to outdated result returned
48
-        // from isDevicePermissionGranted method ( for the time period before the first GUM has been resolved) if the
49
-        //  onchange handler is not working.
50
         this._permissionsApiSupported = new Promise(resolve => {
46
         this._permissionsApiSupported = new Promise(resolve => {
51
             if (!navigator.permissions) {
47
             if (!navigator.permissions) {
52
                 resolve(false);
48
                 resolve(false);
60
 
56
 
61
             promises.push(navigator.permissions.query({ name: VIDEO_PERMISSION_NAME })
57
             promises.push(navigator.permissions.query({ name: VIDEO_PERMISSION_NAME })
62
                 .then(status => {
58
                 .then(status => {
59
+                    this._handlePermissionsChange({
60
+                        [MediaType.VIDEO]: this._parsePermissionState(status)
61
+                    });
63
                     status.onchange = function() {
62
                     status.onchange = function() {
64
                         try {
63
                         try {
65
                             self._handlePermissionsChange({
64
                             self._handlePermissionsChange({
76
 
75
 
77
             promises.push(navigator.permissions.query({ name: AUDIO_PERMISSION_NAME })
76
             promises.push(navigator.permissions.query({ name: AUDIO_PERMISSION_NAME })
78
                 .then(status => {
77
                 .then(status => {
78
+                    this._handlePermissionsChange({
79
+                        [MediaType.AUDIO]: this._parsePermissionState(status)
80
+                    });
79
                     status.onchange = function() {
81
                     status.onchange = function() {
80
                         try {
82
                         try {
81
                             self._handlePermissionsChange({
83
                             self._handlePermissionsChange({
195
      * @param {'audio'|'video'} [type] - type of devices to check,
197
      * @param {'audio'|'video'} [type] - type of devices to check,
196
      *      undefined stands for both 'audio' and 'video' together
198
      *      undefined stands for both 'audio' and 'video' together
197
      * @returns {Promise<boolean>}
199
      * @returns {Promise<boolean>}
198
-     *
199
-     * NOTE: We don't cache the result from the query because this can potentialy lead to outdated result returned
200
-     * from this method ( for the time period before the first GUM has been resolved) if the onchange handler is not
201
-     * working.
202
      */
200
      */
203
     isDevicePermissionGranted(type) {
201
     isDevicePermissionGranted(type) {
204
         return new Promise(resolve => {
202
         return new Promise(resolve => {

Loading…
取消
儲存