Skip to content

In Vue 2.5 ,the use of MessageChannel in nextTick function will lead to audio can not play in some mobile browsers. #7109

@ustbhuangyi

Description

@ustbhuangyi

Version

2.5.8

Reproduction link

https://codesandbox.io/s/vpomxl5p3

Steps to reproduce

Click the 'click me' button and the audio will play.

What is expected?

It can play well in all of the modern browsers that support audio.

What is actually happening?

In PC browsers, it can play well. However, in some mobile browsers, such as iOS Safari、iOS Wechat Webview、Android Chrome,it can not play.


In Vue 2.4 or below, the nextTick function use microTask, like MutationObserver or Promise at first,the click callback and audio play function are in the same tick,so it can play well in all browsers.

Howerver, in Vue 2.5 ,macroTask will be used in DOM action, so the click callback and audio play function are not in the same tick. If we just use setTimeout 0, it will be fine, but actually MessageChannel will be firstly used because of the priority, which lead to the audio can not play in some mobile browsers mentioned above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions