Commit 497bacb4 authored by Matt Reynolds's avatar Matt Reynolds Committed by Commit Bot

Avoid overflowing the stack when disconnecting gamepads

On Mac, disconnecting an Xbox controller while a rumble effect
is active may cause Chrome to recursively call
AbstractHapticGamepad::Shutdown until the stack is exhausted.

When shutting down a haptic gamepad with an ongoing vibration
effect, Chrome calls SetZeroVibration to stop the effect before
closing the connection to the gamepad. If the gamepad is no
longer connected, this command will fail. In XboxDataFetcher on
Mac, this failure triggers another call to Shutdown.

To fix this, AbstractHapticGamepad::Shutdown will check for
re-entry and abort if the gamepad is already shutting down.

BUG=982902

Change-Id: I9d2f4831810bb1a9f124ffecdfda83b4b322df92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1705536Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678358}
parent 77c2d072
......@@ -24,6 +24,8 @@ AbstractHapticGamepad::~AbstractHapticGamepad() {
void AbstractHapticGamepad::Shutdown() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (is_shut_down_)
return;
if (playing_effect_callback_) {
sequence_id_++;
SetZeroVibration();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment