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: gdi printing in silent printing mode #25679

Merged
merged 1 commit into from
Sep 30, 2020

Conversation

RobertBorg
Copy link
Contributor

@RobertBorg RobertBorg commented Sep 29, 2020

Description of Change

For windows print_text_with_gdi is set to the value of is_modifiable
but these code paths are not taken for silent printing.
src\printing\printing_context.cc:40
src\printing\print_settings_conversion.cc:211

this fixes #22577

Checklist

Release Notes

Notes: Fixed GdiTextPrinting when used with silent printing.

for windows print_text_with_gdi is set to the value of is_modifiable
but this code path is not taken for silent printing
@RobertBorg RobertBorg requested a review from a team as a code owner September 29, 2020 10:23
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Sep 29, 2020
@welcome
Copy link

welcome bot commented Sep 29, 2020

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

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

thanks!!

@codebytere
Copy link
Member

@RobertBorg once this merges, could you please backport it to the affected release lines? It'll need manual backport since it's a patch sadly

@RobertBorg
Copy link
Contributor Author

@RobertBorg once this merges, could you please backport it to the affected release lines? It'll need manual backport since it's a patch sadly

I'm happy to do the changes but i might have trouble verifying them as last i tried building 10-x-y it failed. We'll see how it goes.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 30, 2020
@codebytere codebytere merged commit e9876ae into electron:master Sep 30, 2020
@welcome
Copy link

welcome bot commented Sep 30, 2020

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link

release-clerk bot commented Sep 30, 2020

Release Notes Persisted

Fixed GdiTextPrinting when used with silent printing.

@trop
Copy link
Contributor

trop bot commented Sep 30, 2020

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

@trop
Copy link
Contributor

trop bot commented Sep 30, 2020

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

@trop
Copy link
Contributor

trop bot commented Sep 30, 2020

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

@RobertBorg RobertBorg deleted the fix_gdi_with_silent_printing branch September 30, 2020 19:15
@trop
Copy link
Contributor

trop bot commented Oct 1, 2020

@RobertBorg has manually backported this PR to "9-x-y", please check out #25724

@trop
Copy link
Contributor

trop bot commented Oct 2, 2020

@RobertBorg has manually backported this PR to "10-x-y", please check out #25740

@trop
Copy link
Contributor

trop bot commented Oct 2, 2020

@RobertBorg has manually backported this PR to "11-x-y", please check out #25744

@codebytere
Copy link
Member

codebytere commented Oct 14, 2020

@RobertBorg this unfortunately caused a regression in silent mode - if you run https://gist.github.com/0c1c8affb9262ae83bde4d08d3401f0c and set silent: true in options instead of pageRanges and then run it a few times you'll pretty quickly see the following crash:

9:05:26 PM[1356:1013/210525.939:FATAL:emf_win.cc(172)] Check failed: success.
9:05:26 PMBacktrace:
9:05:26 PMbase::debug::CollectStackTrace [0x00007FF75DF26472+18] (o:\base\debug\stack_trace_win.cc:303)
9:05:26 PMbase::debug::StackTrace::StackTrace [0x00007FF75DE93172+18] (o:\base\debug\stack_trace.cc:195)
9:05:26 PMlogging::LogMessage::~LogMessage [0x00007FF75DEA9327+215] (o:\base\logging.cc:551)
9:05:26 PMlogging::LogMessage::~LogMessage [0x00007FF75DEA9F70+16] (o:\base\logging.cc:544)
9:05:26 PMprinting::Emf::SafePlaybackProc [0x00007FF75E65F6A2+130] (o:\printing\emf_win.cc:173)
9:05:26 PMNtGdiXLATEOBJ_iXlate [0x00007FFD2EA852F3+67491]
9:05:26 PMEnumEnhMetaFile [0x00007FFD2FA7D2E2+82]
9:05:26 PMprinting::Emf::SafePlayback [0x00007FF75E65F5B6+278] (o:\printing\emf_win.cc:117)
9:05:26 PMprinting::PrintedDocument::RenderPrintedPage [0x00007FF761063996+538] (o:\printing\printed_document_win.cc:71)
9:05:26 PMprinting::PrintJobWorker::SpoolPage [0x00007FF7605A13CD+279] (o:\chrome\browser\printing\print_job_worker.cc:517)
9:05:26 PMprinting::PrintJobWorker::OnNewPageHelperGdi [0x00007FF7605A0EED+189] (o:\chrome\browser\printing\print_job_worker.cc:441)
9:05:26 PMprinting::PrintJobWorker::OnNewPage [0x00007FF7605A0C11+177] (o:\chrome\browser\printing\print_job_worker.cc:401)
9:05:26 PMbase::TaskAnnotator::RunTask [0x00007FF75DEF35F0+448] (o:\base\task\common\task_annotator.cc:163)
9:05:26 PMbase::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl [0x00007FF75E971CB7+519] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:333)
9:05:26 PMbase::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork [0x00007FF75E9718F6+198] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:254)
9:05:26 PMbase::MessagePumpDefault::Run [0x00007FF75E9558E1+145] (o:\base\message_loop\message_pump_default.cc:41)
9:05:26 PMbase::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run [0x00007FF75E9725CD+381] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:450)
9:05:26 PMbase::RunLoop::Run [0x00007FF75DED5C5E+942] (o:\base\run_loop.cc:126)
9:05:26 PMbase::Thread::Run [0x00007FF75DF11CF7+231] (o:\base\threading\thread.cc:311)
9:05:26 PMbase::Thread::ThreadMain [0x00007FF75DF1216B+1115] (o:\base\threading\thread.cc:385)
9:05:26 PMbase::`anonymous namespace'::ThreadFunc [0x00007FF75DF38CB2+242] (o:\base\threading\platform_thread_win.cc:103)
9:05:26 PMBaseThreadInitThunk [0x00007FFD2F416FD4+20]
9:05:26 PMRtlUserThreadStart [0x00007FFD30BBCEC1+33]
9:05:26 PMTask trace:
9:05:26 PMBacktrace:
9:05:26 PMprinting::PrintJobWorker::PostWaitForPage [0x00007FF7605A0DFC+130] (o:\chrome\browser\printing\print_job_worker.cc:383)
9:05:26 PMprinting::PrintJob::StartPrinting [0x00007FF7605A2FBD+461] (o:\chrome\browser\printing\print_job.cc:183)
9:05:26 PMIPC::`anonymous namespace'::ChannelAssociatedGroupController::Accept [0x00007FF75EA5FD8B+1659] (o:\ipc\ipc_mojo_bootstrap.cc:896)
9:05:26 PMmojo::SimpleWatcher::Context::Notify [0x00007FF75E09614C+302] (o:\mojo\public\cpp\system\simple_watcher.cc:99)

I opened #25937 to follow up

@RobertBorg
Copy link
Contributor Author

@RobertBorg this unfortunately caused a regression in silent mode - if you run https://gist.github.com/0c1c8affb9262ae83bde4d08d3401f0c and set silent: true in options instead of pageRanges and then run it a few times you'll pretty quickly see the following crash:

9:05:26 PM[1356:1013/210525.939:FATAL:emf_win.cc(172)] Check failed: success.
9:05:26 PMBacktrace:
9:05:26 PMbase::debug::CollectStackTrace [0x00007FF75DF26472+18] (o:\base\debug\stack_trace_win.cc:303)
9:05:26 PMbase::debug::StackTrace::StackTrace [0x00007FF75DE93172+18] (o:\base\debug\stack_trace.cc:195)
9:05:26 PMlogging::LogMessage::~LogMessage [0x00007FF75DEA9327+215] (o:\base\logging.cc:551)
9:05:26 PMlogging::LogMessage::~LogMessage [0x00007FF75DEA9F70+16] (o:\base\logging.cc:544)
9:05:26 PMprinting::Emf::SafePlaybackProc [0x00007FF75E65F6A2+130] (o:\printing\emf_win.cc:173)
9:05:26 PMNtGdiXLATEOBJ_iXlate [0x00007FFD2EA852F3+67491]
9:05:26 PMEnumEnhMetaFile [0x00007FFD2FA7D2E2+82]
9:05:26 PMprinting::Emf::SafePlayback [0x00007FF75E65F5B6+278] (o:\printing\emf_win.cc:117)
9:05:26 PMprinting::PrintedDocument::RenderPrintedPage [0x00007FF761063996+538] (o:\printing\printed_document_win.cc:71)
9:05:26 PMprinting::PrintJobWorker::SpoolPage [0x00007FF7605A13CD+279] (o:\chrome\browser\printing\print_job_worker.cc:517)
9:05:26 PMprinting::PrintJobWorker::OnNewPageHelperGdi [0x00007FF7605A0EED+189] (o:\chrome\browser\printing\print_job_worker.cc:441)
9:05:26 PMprinting::PrintJobWorker::OnNewPage [0x00007FF7605A0C11+177] (o:\chrome\browser\printing\print_job_worker.cc:401)
9:05:26 PMbase::TaskAnnotator::RunTask [0x00007FF75DEF35F0+448] (o:\base\task\common\task_annotator.cc:163)
9:05:26 PMbase::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl [0x00007FF75E971CB7+519] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:333)
9:05:26 PMbase::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork [0x00007FF75E9718F6+198] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:254)
9:05:26 PMbase::MessagePumpDefault::Run [0x00007FF75E9558E1+145] (o:\base\message_loop\message_pump_default.cc:41)
9:05:26 PMbase::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run [0x00007FF75E9725CD+381] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:450)
9:05:26 PMbase::RunLoop::Run [0x00007FF75DED5C5E+942] (o:\base\run_loop.cc:126)
9:05:26 PMbase::Thread::Run [0x00007FF75DF11CF7+231] (o:\base\threading\thread.cc:311)
9:05:26 PMbase::Thread::ThreadMain [0x00007FF75DF1216B+1115] (o:\base\threading\thread.cc:385)
9:05:26 PMbase::`anonymous namespace'::ThreadFunc [0x00007FF75DF38CB2+242] (o:\base\threading\platform_thread_win.cc:103)
9:05:26 PMBaseThreadInitThunk [0x00007FFD2F416FD4+20]
9:05:26 PMRtlUserThreadStart [0x00007FFD30BBCEC1+33]
9:05:26 PMTask trace:
9:05:26 PMBacktrace:
9:05:26 PMprinting::PrintJobWorker::PostWaitForPage [0x00007FF7605A0DFC+130] (o:\chrome\browser\printing\print_job_worker.cc:383)
9:05:26 PMprinting::PrintJob::StartPrinting [0x00007FF7605A2FBD+461] (o:\chrome\browser\printing\print_job.cc:183)
9:05:26 PMIPC::`anonymous namespace'::ChannelAssociatedGroupController::Accept [0x00007FF75EA5FD8B+1659] (o:\ipc\ipc_mojo_bootstrap.cc:896)
9:05:26 PMmojo::SimpleWatcher::Context::Notify [0x00007FF75E09614C+302] (o:\mojo\public\cpp\system\simple_watcher.cc:99)

I opened #25937 to follow up

While trying to reproduce this i built 2c68bad in release configuration. used your gist. changed pageRanges to silent:true and added app.commandLine.appendSwitch('enable-features', 'GdiTextPrinting'); to main.js 8else i don't think my code change has any effect whatsoever). I managed to do 50 prints without a crash.

I do however remember that i needed to build release in order to be abel to print at all. Which configuration are you using?

@RobertBorg
Copy link
Contributor Author

I'm able to trigger it now by clicking faster (was on rdp before)

Im getting it mixed with this crash

[24012:1015/161034.813:FATAL:scoped_refptr.h(235)] Check failed: ptr_. 
Backtrace:
        base::debug::CollectStackTrace [0x00007FF63A736472+18] (o:\base\debug\stack_trace_win.cc:303)
        base::debug::StackTrace::StackTrace [0x00007FF63A6A3172+18] (o:\base\debug\stack_trace.cc:195)
        logging::LogMessage::~LogMessage [0x00007FF63A6B9327+215] (o:\base\logging.cc:551)
        logging::LogMessage::~LogMessage [0x00007FF63A6B9F70+16] (o:\base\logging.cc:544)
        scoped_refptr<base::internal::BindStateBase>::operator-> [0x00007FF636E43415+81] (o:\base\memory\scoped_refptr.h:236)
        printing::PrintViewManagerBase::OnComposePdfDone [0x00007FF63BD72D5E+318] (o:\chrome\browser\printing\print_view_manager_base.cc:328)
        base::internal::FunctorTraits<void (printing::PrintViewManagerBase::*)(const gfx::Size &, const gfx::Rect &, const gfx::Point &, std::__1::unique_ptr<printing::PrintManager::DelayedFrameDispatchHelper,std::__1::default_delete<printing::PrintManager::Delay [0x00007FF63BD73ED8+152] (o:\base\bind_internal.h:498)
        base::internal::Invoker<base::internal::BindState<void (printing::PrintViewManagerBase::*)(const gfx::Size &, const gfx::Rect &, const gfx::Point &, std::__1::unique_ptr<printing::PrintManager::DelayedFrameDispatchHelper,std::__1::default_delete<printing: [0x00007FF63BD73E2A+122] (o:\base\bind_internal.h:683)
        base::OnceCallback<void (printing::mojom::PrintCompositor_Status, base::ReadOnlySharedMemoryRegion)>::Run [0x00007FF636FF7142+64] (o:\base\callback.h:100)
        printing::PrintCompositeClient::OnDidCompositeDocumentToPdf [0x00007FF63B0B7358+72] (o:\components\printing\browser\print_composite_client.cc:300)
        base::internal::Invoker<base::internal::BindState<void (printing::PrintCompositeClient::*)(int, base::OnceCallback<void (printing::mojom::PrintCompositor_Status, base::ReadOnlySharedMemoryRegion)>, printing::mojom::PrintCompositor_Status, base::ReadOnlySh [0x00007FF63B0B7A2F+95] (o:\base\bind_internal.h:679)
        base::OnceCallback<void (printing::mojom::PrintCompositor_Status, base::ReadOnlySharedMemoryRegion)>::Run [0x00007FF636FF7142+64] (o:\base\callback.h:100)
        printing::mojom::PrintCompositor_CompositeDocumentToPdf_ForwardToCallback::Accept [0x00007FF63A443E28+296] (o:\fake\prefix\gen\components\services\print_compositor\public\mojom\print_compositor.mojom.cc:846)
        mojo::InterfaceEndpointClient::HandleValidatedMessage [0x00007FF63A88C5C4+730] (o:\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc:549)
        mojo::MessageDispatcher::Accept [0x00007FF63B268482+226] (o:\mojo\public\cpp\bindings\lib\message_dispatcher.cc:41)
        mojo::InterfaceEndpointClient::HandleIncomingMessage [0x00007FF63A88D672+66] (o:\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc:356)
        mojo::internal::MultiplexRouter::ProcessIncomingMessage [0x00007FF63A892724+740] (o:\mojo\public\cpp\bindings\lib\multiplex_router.cc:954)
        mojo::internal::MultiplexRouter::Accept [0x00007FF63A8921C2+354] (o:\mojo\public\cpp\bindings\lib\multiplex_router.cc:626)
        mojo::MessageDispatcher::Accept [0x00007FF63B268482+226] (o:\mojo\public\cpp\bindings\lib\message_dispatcher.cc:41)
        mojo::Connector::DispatchMessageW [0x00007FF63A88ADA7+451] (o:\mojo\public\cpp\bindings\lib\connector.cc:502)
        mojo::Connector::ReadAllAvailableMessages [0x00007FF63A88B6B1+257] (o:\mojo\public\cpp\bindings\lib\connector.cc:561)
        mojo::Connector::OnHandleReadyInternal [0x00007FF63A88B499+67] (o:\mojo\public\cpp\bindings\lib\connector.cc:402)
        mojo::SimpleWatcher::OnHandleReady [0x00007FF63A8A5EDD+269] (o:\mojo\public\cpp\system\simple_watcher.cc:273)
        base::TaskAnnotator::RunTask [0x00007FF63A7035F0+448] (o:\base\task\common\task_annotator.cc:163)
        base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl [0x00007FF63B181CB7+519] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:333)
        base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork [0x00007FF63B1818F6+198] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:254)
        base::MessagePumpForUI::DoRunLoop [0x00007FF63A73FB67+247] (o:\base\message_loop\message_pump_win.cc:220)
        base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run [0x00007FF63B1825CD+381] (o:\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:450)
        base::RunLoop::Run [0x00007FF63A6E5C5E+942] (o:\base\run_loop.cc:126)
        content::BrowserMainLoop::MainMessageLoopRun [0x00007FF639A59FC4+148] (o:\content\browser\browser_main_loop.cc:1459)
        content::BrowserMainRunnerImpl::Run [0x00007FF639A5BF3F+143] (o:\content\browser\browser_main_runner_impl.cc:151)
        content::BrowserMain [0x00007FF639A56F90+272] (o:\content\browser\browser_main.cc:47)
        content::RunBrowserProcessMain [0x00007FF6399241B1+89] (o:\content\app\content_main_runner_impl.cc:507)
        content::ContentMainRunnerImpl::RunServiceManager [0x00007FF639924F85+973] (o:\content\app\content_main_runner_impl.cc:980)
        content::ContentMainRunnerImpl::Run [0x00007FF639924B8A+426] (o:\content\app\content_main_runner_impl.cc:866)
        content::RunContentProcess [0x00007FF637F1F86D+1629] (o:\content\app\content_main.cc:375)
        content::ContentMain [0x00007FF637F1F957+61] (o:\content\app\content_main.cc:401)
        wWinMain [0x00007FF636E41464+840] (o:\electron\shell\app\electron_main.cc:210)
        __scrt_common_main_seh [0x00007FF63ECA0272+262] (d:\A01\_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
        BaseThreadInitThunk [0x00007FFA8B637034+20]
        RtlUserThreadStart [0x00007FFA8C15CEC1+33]
Task trace:
Backtrace:
        mojo::SimpleWatcher::Context::Notify [0x00007FF63A8A614C+302] (o:\mojo\public\cpp\system\simple_watcher.cc:99)

both of which seems to be triggered when printing too fast. If i put a intervall printing every 600ms it seems to be able to go on forever (i kill it off at 100)
but if i set it to 500 it dies after 2-3 prints.

Could the cause be the same for both of them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Printing with silent mode and GdiTextPrinting on Windows is broken
2 participants