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

Make SpeechSynthesisUtterance an ActiveDOMObject #16714

Conversation

szewai
Copy link
Contributor

@szewai szewai commented Aug 15, 2023

42ffbe1

Make SpeechSynthesisUtterance an ActiveDOMObject
https://bugs.webkit.org/show_bug.cgi?id=260214
rdar://113921763

Reviewed by Ryosuke Niwa.

Currently dispatching event to SpeechSynthesisUtterance can lead to crash due to GC. To fix that, we now keep wrapper
of SpeechSynthesisUtterance alive until there is no more event to be dispatched. This can happen in two cases:
1. SpeechSynthesisUtterance is not processed yet, and is removed from SpeechSynthesis's queue (i.e. the utterance will
not be processed).
2. SpeechSynthesisUtterance is being processed, and it finishes dispatching end or error event -- these two events are
the last events to be fired on an untterance according to spec: https://wicg.github.io/speech-api/#utterance-events.

* Source/WebCore/Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::setPlatformSynthesizer):
(WebCore::SpeechSynthesis::cancel):
(WebCore::SpeechSynthesis::clearUtteranceQueue):
* Source/WebCore/Modules/speech/SpeechSynthesis.h:
* Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp:
(WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance):
(WebCore::SpeechSynthesisUtterance::eventOccurred):
(WebCore::SpeechSynthesisUtterance::errorEventOccurred):
(WebCore::SpeechSynthesisUtterance::dispatchEventAndUpdateState):
(WebCore::SpeechSynthesisUtterance::setIsActiveForEventDispatch):
(WebCore::SpeechSynthesisUtterance::activeDOMObjectName const):
(WebCore::SpeechSynthesisUtterance::virtualHasPendingActivity const):
* Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h:
* Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl:

Canonical link: https://commits.webkit.org/266959@main

48f207c

Misc iOS, tvOS & watchOS macOS Linux Windows
❌ πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@szewai szewai self-assigned this Aug 15, 2023
@szewai szewai added the Accessibility For bugs related to accessibility. label Aug 15, 2023
@szewai szewai requested review from twilco and rniwa August 15, 2023 19:28
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 15, 2023
@szewai szewai removed the merging-blocked Applied to prevent a change from being merged label Aug 15, 2023
@szewai szewai force-pushed the eng/Make-SpeechSynthesisUtterance-an-ActiveDOMObject branch from 472814b to c8b007f Compare August 15, 2023 23:58
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 16, 2023
Copy link
Member

@rniwa rniwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me on the original PR.

@szewai szewai removed the merging-blocked Applied to prevent a change from being merged label Aug 16, 2023
@szewai szewai force-pushed the eng/Make-SpeechSynthesisUtterance-an-ActiveDOMObject branch from c8b007f to 48f207c Compare August 16, 2023 18:33
@szewai szewai added the merge-queue Applied to send a pull request to merge-queue label Aug 16, 2023
https://bugs.webkit.org/show_bug.cgi?id=260214
rdar://113921763

Reviewed by Ryosuke Niwa.

Currently dispatching event to SpeechSynthesisUtterance can lead to crash due to GC. To fix that, we now keep wrapper
of SpeechSynthesisUtterance alive until there is no more event to be dispatched. This can happen in two cases:
1. SpeechSynthesisUtterance is not processed yet, and is removed from SpeechSynthesis's queue (i.e. the utterance will
not be processed).
2. SpeechSynthesisUtterance is being processed, and it finishes dispatching end or error event -- these two events are
the last events to be fired on an untterance according to spec: https://wicg.github.io/speech-api/#utterance-events.

* Source/WebCore/Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::setPlatformSynthesizer):
(WebCore::SpeechSynthesis::cancel):
(WebCore::SpeechSynthesis::clearUtteranceQueue):
* Source/WebCore/Modules/speech/SpeechSynthesis.h:
* Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp:
(WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance):
(WebCore::SpeechSynthesisUtterance::eventOccurred):
(WebCore::SpeechSynthesisUtterance::errorEventOccurred):
(WebCore::SpeechSynthesisUtterance::dispatchEventAndUpdateState):
(WebCore::SpeechSynthesisUtterance::setIsActiveForEventDispatch):
(WebCore::SpeechSynthesisUtterance::activeDOMObjectName const):
(WebCore::SpeechSynthesisUtterance::virtualHasPendingActivity const):
* Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h:
* Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl:

Canonical link: https://commits.webkit.org/266959@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Make-SpeechSynthesisUtterance-an-ActiveDOMObject branch from 48f207c to 42ffbe1 Compare August 16, 2023 21:31
@webkit-commit-queue
Copy link
Collaborator

Committed 266959@main (42ffbe1): https://commits.webkit.org/266959@main

Reviewed commits have been landed. Closing PR #16714 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 42ffbe1 into WebKit:main Aug 16, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility For bugs related to accessibility.
Projects
None yet
5 participants