Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Chrome freezes on windows when opened with WWW::Mechanize::Chrome

by bakiperl (Beadle)
on Oct 14, 2021 at 15:02 UTC ( [id://11137511]=perlquestion: print w/replies, xml ) Need Help??

bakiperl has asked for the wisdom of the Perl Monks concerning the following question:

My WMC scripts have suddenly stopped working on windows, but they still work fine on Linux. I am not sure if it was caused by the windows updates or the recent module updates. I hope Corion can check this.
Here is a simple script that causes the freezing of the browser. It has been tested on 3 different machines and the result is the same.
#!/usr/bin/perl -w use strict; use warnings; use 5.012; use WWW::Mechanize::Chrome; use Log::Log4perl ':easy'; Log::Log4perl->easy_init($TRACE); my $mech = WWW::Mechanize::Chrome->new( headless => 0, ); use Data::Dumper; my $res = $mech->get('https://egp.rutgers.edu/wmc.html'); say Dumper $mech->getResourceTree_future()->get; $mech->sleep (20);

Replies are listed 'Best First'.
Re: Chrome freezes on windows when opened with WWW::Mechanize::Chrome
by Discipulus (Canon) on Oct 15, 2021 at 10:57 UTC
    Hello bakiperl,

    some time ago I was suggested to have a different browser especially installed for mechanize things, so you dont run in the problem you encountered. Chromium is a valuable choice and keep it away from your PATH

    In the program then..

    my $url = 'perlmonks.org'; my $chromium_path = "C:/_CHROMIUM/Chrome-bin/chrome.exe"; my $chromium_arg = "--remote-debugging-port=9222"; # dont reme +mber if needed, but useful to know :) #################################### my $mech = WWW::Mechanize::Chrome->new( mute_audio => 1, autoclose => 0, incognito => 0, launch_exe => $chromium_path, ); $mech->get( $url );

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      my $chromium_arg = "--remote-debugging-port=9222"; # dont remember if needed, but useful to know :)

      Letting you know... it isn't needed. The setup works fine by default without that added argument.

      I just installed the distribution, and I'm so thankful I saw your post first as I'm grateful I don't need to actually install a Google product. Chromium works perfectly!

        Stevieb,
        I took your advice and I switched to Chromium to avoid the annoying google chrome auto-update.
        FYI, Chromium version 94.0... has also caused the freezing of the browser. So I am going to hold on to version 93.0. for now.
        Thank you.
Re: Chrome freezes on windows when opened with WWW::Mechanize::Chrome
by Corion (Patriarch) on Oct 14, 2021 at 17:21 UTC

    I cannot reproduce the problem using your code. As you have the $TRACE output enabled, maybe you can show the output up to the point where the program "freezes".

      Corion,
      It turns out that the recent google chrome updates are the cause of the problem. The newer version stops responding immediately after you execute the script.
      I downgraded chrome to an earlier version and things are back running normally.

        Would you please share the Chrome versions in question here? Both the last one that appears to work and the one that you believe broke things?

        I use Corion's distribution here from time-to-time, and am about to deploy it for some tests at work in the coming week or so. I'd like to do some testing on the issue before I have our guys deploying software.

      Corion,
      Just in case this can help tracking the issue that is causing chrome/chromium version 94. and 95. to freeze, I added the launch_arg option and the result is shown below:
      my $mech = WWW::Mechanize::Chrome->new( headless => 0, launch_arg => [ " --enable-logging", "--v=1" ] );
      chrome_bebug.log file
      [10576:11820:1029/142219.260:ERROR:chrome_browser_main_extra_parts_met +rics.cc(230)] crbug.com/1216328: Checking Bluetooth availability star +ted. Please report if there is no report that this ends. [10576:11820:1029/142219.260:ERROR:chrome_browser_main_extra_parts_met +rics.cc(233)] crbug.com/1216328: Checking Bluetooth availability ende +d.

        This must be some weird difference between our setups, since I do not get any kind of Chrome freeze with that on either Linux or Windows.

        Maybe if you launch Chrome with a completely fresh profile (without any plugins), something different shows up?

        use File::Temp 'tempdir'; my $mech = WWW::Mechanize::Chrome->new( headless => 0, data_directory => tempdir(CLEANUP => 1 ), launch_arg => [ " --enable-logging", "--v=1" ] );
Re: Chrome freezes on windows when opened with WWW::Mechanize::Chrome
by Bod (Parson) on Oct 17, 2021 at 00:14 UTC

    Can I ask what Perl you are running on Windows?

    I have tried to install WWW::Mechanize::Chrome several times on Strawberry Perl v32. Every time it has failed. Last evening I tried on a clean install of Strawberry Perl. It failed again, hanging on one of the tests (I can't recall which one and I am nowhere near that machine atm). It seems it has failed tests on Windows with Perl v32 so I was planning to get a Raspberry Pi 3 mostly to run WWW::Mechanize::Chrome.

    But...you must have WWW::Mechanize::Chrome running on Windows...

      Bod,
      I am using Strawberry Perl (v5.32.1). Try cpanm -v --force WWW::Mechanize::Chrome to install WMC for strawberry Perl. The issue is discussed here: 11126245
        I am using Strawberry Perl (v5.32.1)

        So we are using the same version...

        Try cpanm -v --force WWW::Mechanize::Chrome to install WMC for strawberry Perl

        That's pretty much what I tried when cpanm WWW::Mechanize::Chrome failed.
        I've just tried again on a different machine and it hangs in the same place...

        t/50-gh63-encode-response-content.t ........... 2/4

        Here are the preceding lines if it helps with diagnosis.

Re: Chrome freezes on windows when opened with WWW::Mechanize::Chrome
by wireb (Initiate) on Nov 09, 2021 at 18:04 UTC
    I am hitting a similar hang on multiple computers all running windows and the latest Chrome.
    Was this ever solved?

    My specific setup:
    Version 95.0.4638.69 (Official Build) (64-bit) <- program was working prior to this release / update
    WWW::Mechanize::Chrome is up to date. (0.68)
    This is perl 5, version 30, subversion 3 (v5.30.3) built for MSWin32-x64-multi-thread

    Dissolved my script down to the following that will cause a recreate. Typically stops responding after loading CNN during the sleep delay.
    Note if you remove the delays you can get a few more of the pages to load but eventually the hang returns.

    #################################################################### # This is a test of WWW::Mechanize::Chrome #################################################################### use strict; use warnings; use File::Path; use Log::Log4perl qw(:easy); # used by WWW::Mechanize::Chrome use WWW::Mechanize::Chrome; my $chrome = ""; my $page = ""; Log::Log4perl->easy_init($TRACE); # Set priority of root logger to ER +ROR # clean up data_directory to start fresh each time. mkdir("/temp/"); rmtree("/temp/mechaChrome/"); mkdir("/temp/mechaChrome/"); $chrome = WWW::Mechanize::Chrome->new( #autoclose => 0, # when script is complete close the browse +r (default yes) data_directory => '/temp/mechaChrome/', # this fixes the "Do yo +u maybe have a non-debug instance of Chrome already running?" timeout + error by forcing a new instance of chrome. start_url => 'https:\\www.cnn.com', launch_arg => [ " --enable-logging", "--v=1" ] ); print("sleeping\n"); sleep(30); print("Load reddit\n"); $page = $chrome->get("https://www.reddit.com/"); print("sleeping\n"); sleep(30); print("Load slashdot\n"); $page = $chrome->get("https://slashdot.org/"); print("sleeping\n"); sleep(30); print("Script done\n"); exit(0);

    I have the trace output from the command prompt not sure if there is a second file anywhere I should grab for debug. (added the launch_arg => " --enable-logging", "--v=1" but not sure where that output goes)
    Is there a preferred place to paste the output? (it's quite large)

    Thanks,
    Wire

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11137511]
Approved by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-03-19 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found