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: crash on window.print() #19601

Merged
merged 1 commit into from Aug 5, 2019
Merged

fix: crash on window.print() #19601

merged 1 commit into from Aug 5, 2019

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Aug 2, 2019

Description of Change

Fixes #19539.

window.print() doesn't invoke PrintViewManagerBase::PrintNowInternal, so when we moved

  registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
                content::NotificationService::AllSources());

into that function from PrintViewManagerBase::CreateNewPrintJob() we inadvertently created a side-effect wherein in PrintViewManagerBase::ReleasePrintJob() it would try to unregister a notification listener which wasn't registered, and would therefore CHECK on found != registered_.end().

This fixes that by guarding the unregistration with a null check on callback_, which would only be non-null when in the call chain of our webContents.print() implementation, since callback_ is a member we patched in ourselves as part of that method.

cc @jkleinsc @PalmerAL @deepak1556

Checklist

Release Notes

Notes: Fixed a crash in window.print().

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/5-0-x labels Aug 2, 2019
@codebytere codebytere requested a review from a team as a code owner August 2, 2019 22:46
@electron-cation electron-cation bot added new-pr 🌱 PR opened in the last 24 hours and removed new-pr 🌱 PR opened in the last 24 hours labels Aug 2, 2019
@jkleinsc jkleinsc merged commit 0bb227f into master Aug 5, 2019
@release-clerk
Copy link

release-clerk bot commented Aug 5, 2019

Release Notes Persisted

Fixed a crash in window.print().

@jkleinsc jkleinsc deleted the fix-window-print branch August 5, 2019 13:19
@trop
Copy link
Contributor

trop bot commented Aug 5, 2019

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

@trop
Copy link
Contributor

trop bot commented Aug 5, 2019

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

@trop
Copy link
Contributor

trop bot commented Aug 5, 2019

I have automatically backported this PR to "7-0-x", please check out #19623

@sofianguy sofianguy added this to 7.0.0-beta.2 in 7.2.x Aug 7, 2019
@trop
Copy link
Contributor

trop bot commented Aug 7, 2019

A maintainer has manually backported this PR to "6-0-x", please check out #19677

@trop
Copy link
Contributor

trop bot commented Aug 7, 2019

A maintainer has manually backported this PR to "5-0-x", please check out #19678

@sofianguy sofianguy added this to Fixed for 6.0.2 in 6.1.x Aug 14, 2019
@sofianguy sofianguy added this to Fixed in 5.0.10 in 5.0.x Aug 20, 2019
@rgarcia1990
Copy link

i have the same problem in electron v9, will it be solved soon?

@codebytere
Copy link
Member Author

@rgarcia1990 this should be fixed in v9. If you are still having issues, please fill out a new issue with a proper repro and other aspects of the template filled.

@rgarcia1990
Copy link

@rgarcia1990 this should be fixed in v9. If you are still having issues, please fill out a new issue with a proper repro and other aspects of the template filled.

it seems that the problem is when you try to print a page from version 9 using pdf viewer... it easy to reproduce just load a browserwindow from an url with pdf and try to print.

@rgarcia1990
Copy link

rgarcia1990 commented Jul 8, 2020

@rgarcia1990 this should be fixed in v9. If you are still having issues, please fill out a new issue with a proper repro and other aspects of the template filled.

i created the issue for that problem. It is very important for me if you can help me! Thanks for considering my request!
#24458

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch backwards-compatible bug fixes
Projects
No open projects
5.0.x
Fixed in 5.0.10
6.1.x
Fixed for 6.0.2
7.2.x
Fixed in 7.0.0-beta.2
Development

Successfully merging this pull request may close these issues.

Crash when printing to PDF in 5.0.5+
5 participants