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

fix: destroy WebContents synchronously on shutdown #15541

Merged
merged 1 commit into from Nov 8, 2018

Conversation

Projects
None yet
6 participants
@zcbenz
Copy link
Member

commented Nov 2, 2018

Description of Change

Destroying WebContents asynchronously on shutdown may delay the destroying task after the shutdown task, resulting in an assertion in ResourceDispatcherHostImpl::OnShutdown.

This PR destroys WebContents synchronously on shutdown, so we can fix #15133 without breaking #8930.

I have also added notes for DestroyWebContents on how to use it correctly.

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are changed or added
  • relevant documentation is changed or added
  • PR title follows semantic commit guidelines

Release Notes

Notes: Fix crash on exit when using BrowserView.

@zcbenz zcbenz added the target/4-0-x label Nov 2, 2018

@zcbenz zcbenz requested review from as code owners Nov 2, 2018

@zcbenz zcbenz force-pushed the destroy-webcontents-sync branch 2 times, most recently from 9f28853 to 7416c2e Nov 2, 2018

@zcbenz

This comment has been minimized.

Copy link
Member Author

commented Nov 2, 2018

This PR has accidentally revealed a crash in other place:

* thread #1: tid = 0x83cc89, 0x000000010122ee88 Electron Framework`::GuestCurrentlyAudibleCallback() + 8 at browser_plugin_embedder.cc:200, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x190)
  * frame #0: 0x000000010122ee88 Electron Framework`::GuestCurrentlyAudibleCallback() + 8 at browser_plugin_embedder.cc:200 [opt]
    frame #1: 0x00000001033de9c1 Electron Framework`::ForEachGuest() [inlined] Run + 161 at callback.h:129 [opt]
    frame #2: 0x00000001033de96c Electron Framework`::ForEachGuest() + 76 at web_view_manager.cc:69 [opt]
    frame #3: 0x000000010122ef36 Electron Framework`::AreAnyGuestsCurrentlyAudible() + 166 at browser_plugin_embedder.cc:207 [opt]
    frame #4: 0x00000001017cf5ec Electron Framework`::OnAudioStateChanged() + 60 at web_contents_impl.cc:1587 [opt]
    frame #5: 0x000000010153751a Electron Framework`::UpdateStreams() + 426 at audio_stream_monitor.cc:195 [opt]
    frame #6: 0x0000000101537de3 Electron Framework`::UpdateStreamAudibleStateOnUIThread() + 323 at audio_stream_monitor.cc:157 [opt]
    frame #7: 0x00000001034a4a56 Electron Framework`::RunTask() [inlined] Run + 23 at callback.h:99 [opt]
    frame #8: 0x00000001034a4a3f Electron Framework`::RunTask() + 335 at task_annotator.cc:101 [opt]
    frame #9: 0x00000001034dd76f Electron Framework`::RunTask() + 639 at message_loop.cc:421 [opt]
    frame #10: 0x00000001034dddca Electron Framework`::DoWork() [inlined] DeferOrRunPendingTask + 474 at message_loop.cc:432 [opt]
    frame #11: 0x00000001034dddbe Electron Framework`::DoWork() + 462 at message_loop.cc:480 [opt]
    frame #12: 0x0000000103609cca Electron Framework`::RunWork() + 42 at message_pump_mac.mm:455 [opt]
    frame #13: 0x000000010360ec8a Electron Framework`base::mac::CallWithEHFrame(void () block_pointer) + 10 at call_with_eh_frame_asm.S:36

@zcbenz zcbenz force-pushed the destroy-webcontents-sync branch 3 times, most recently from d5b5a65 to 2ed1a11 Nov 2, 2018

@zcbenz

This comment has been minimized.

Copy link
Member Author

commented Nov 2, 2018

The crash turned out to be a mistake when refactoring.

All tests are passing now.

@MarshallOfSound

This comment has been minimized.

Copy link
Member

commented Nov 2, 2018

@zcbenz The 4.0 backport failed, trop failed to report it because of a GitHub API error. Will work on a fix for trop for that but just a heads up for now 👍

MarshallOfSound added a commit to electron/trop that referenced this pull request Nov 2, 2018

fix: try mark as failure without annotations when the GitHub API fails
Normally this means we send invalid annotations, so let's just send a
failure without them.

E.g. electron/electron#15541
@deepak1556
Copy link
Member

left a comment

LGTM 👍

app.on('ready', function () {
new BrowserView({}) // eslint-disable-line

process.nextTick(() => app.quit())

This comment has been minimized.

Copy link
@deepak1556

deepak1556 Nov 2, 2018

Member

Any reason this has to be on the next tick ?

This comment has been minimized.

Copy link
@zcbenz

zcbenz Nov 2, 2018

Author Member

I'm trying to emulate the original crash case, having process.nextTick or not does not really affect the test.

MarshallOfSound added a commit to electron/trop that referenced this pull request Nov 3, 2018

fix: try mark as failure without annotations when the GitHub API fails (
#64)

Normally this means we send invalid annotations, so let's just send a
failure without them.

E.g. electron/electron#15541
@deepak1556

This comment has been minimized.

Copy link
Member

commented Nov 3, 2018

@zcbenz just remembered, we had disabled a spec in 69 due to the same crash https://github.com/orgs/electron/projects/24#card-13687849, can you try enabling it in this PR ? Thanks!

@zcbenz

This comment has been minimized.

Copy link
Member Author

commented Nov 8, 2018

@zcbenz just remembered, we had disabled a spec in 69 due to the same crash https://github.com/orgs/electron/projects/24#card-13687849, can you try enabling it in this PR ?

The test is timeout on my machine, after quitting the app directly I'm seeing the client_map_.empty() assertion. I'll look into it in another PR.

@zcbenz zcbenz force-pushed the destroy-webcontents-sync branch from 2ed1a11 to d6c0b35 Nov 8, 2018

@zcbenz zcbenz removed the target/4-0-x label Nov 8, 2018

@felixrieseberg
Copy link
Member

left a comment

This makes sense to me and looks good. 👏 for the documentation in code, explains what's going on well!

@codebytere codebytere merged commit 746beb0 into master Nov 8, 2018

27 of 28 checks passed

Backportable? - 4-0-x Cancelled
Details
Absolute Zero
Artifact Comparison No Changes
Details
Semantic Pull Request ready to be squashed
Details
WIP Legacy commit status override — see details
Details
appveyor: win-ia32-debug AppVeyor build succeeded
Details
appveyor: win-ia32-testing AppVeyor build succeeded
Details
appveyor: win-ia32-testing-pr AppVeyor build succeeded
Details
appveyor: win-x64-debug AppVeyor build succeeded
Details
appveyor: win-x64-testing AppVeyor build succeeded
Details
appveyor: win-x64-testing-pr AppVeyor build succeeded
Details
ci/circleci: linux-arm-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-arm-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-arm64-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-arm64-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-checkout Your tests passed on CircleCI!
Details
ci/circleci: linux-ia32-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-ia32-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-ia32-testing-tests Your tests passed on CircleCI!
Details
ci/circleci: linux-x64-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-x64-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-x64-testing-tests Your tests passed on CircleCI!
Details
electron-arm-testing Build #20181108.18 succeeded
Details
electron-arm64-testing Build #20181108.18 succeeded
Details
electron-lint Build #20181108.15 succeeded
Details
electron-mas-testing Build #20181108.16 succeeded
Details
electron-osx-testing Build #20181108.17 succeeded
Details
release-notes Release notes found
@release-clerk

This comment has been minimized.

Copy link

commented Nov 8, 2018

Release Notes Persisted

Fix crash on exit when using BrowserView.

@codebytere codebytere deleted the destroy-webcontents-sync branch Nov 8, 2018

deepak1556 added a commit that referenced this pull request Nov 26, 2018

@deepak1556 deepak1556 referenced this pull request Nov 26, 2018

Merged

fix: switch to mojo proxy resolver (3-1-x) #15813

5 of 5 tasks complete

deepak1556 added a commit that referenced this pull request Nov 26, 2018

@miniak

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2019

/trop run backport-to 3-1-x

@trop

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2019

The backport process for this PR has been manually initiated,
sending your 1's and 0's to "3-1-x" here we go! :D

@trop

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2019

I was unable to backport this PR to "3-1-x" cleanly;
you will need to perform this backport manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.