def Create(self, clear_caches=True): if self._flash_path and not os.path.exists(self._flash_path): logging.warning( 'Could not find Flash at %s. Continuing without Flash.\n' 'To run with Flash, check it out via http://go/read-src-internal', self._flash_path) self._flash_path = None self._InitPlatformIfNeeded() num_retries = 3 for x in range(0, num_retries): returned_browser = None try: # Note: we need to regenerate the browser startup arguments for each # browser startup attempt since the state of the startup arguments # may not be guaranteed the same each time # For example, see: crbug.com/865895#c17 startup_args = self.GetBrowserStartupArgs(self._browser_options) startup_url = self._browser_options.startup_url returned_browser = None browser_backend = desktop_browser_backend.DesktopBrowserBackend( self._platform_backend, self._browser_options, self._browser_directory, self._profile_directory, self._local_executable, self._flash_path, self._is_content_shell) # TODO(crbug.com/811244): Remove when this is handled by shared state. if clear_caches: self._ClearCachesOnStart() returned_browser = browser.Browser( browser_backend, self._platform_backend, startup_args, startup_url=startup_url) # TODO(crbug.com/916086): Move this assertion to callers. if self._browser_options.assert_gpu_compositing: gpu_compositing_checker.AssertGpuCompositingEnabled( returned_browser.GetSystemInfo()) return returned_browser # Do not retry if gpu assertion failure is raised. except gpu_compositing_checker.GpuCompositingAssertionFailure: raise except Exception: # pylint: disable=broad-except report = 'Browser creation failed (attempt %d of %d)' % ( (x + 1), num_retries) if x < num_retries - 1: report += ', retrying' logging.warning(report) # Attempt to clean up things left over from the failed browser startup. try: if returned_browser: returned_browser.DumpStateUponFailure() returned_browser.Close() except Exception: # pylint: disable=broad-except pass # Re-raise the exception the last time through. if x == num_retries - 1: raise
def Create(self): # Init the LocalFirstBinaryManager if this is the first time we're creating # a browser. if local_first_binary_manager.LocalFirstBinaryManager.NeedsInit(): local_first_binary_manager.LocalFirstBinaryManager.Init( self._build_dir, self._local_executable, self.platform.GetOSName(), self.platform.GetArchName()) if self._flash_path and not os.path.exists(self._flash_path): logging.warning( 'Could not find Flash at %s. Continuing without Flash.\n' 'To run with Flash, check it out via http://go/read-src-internal', self._flash_path) self._flash_path = None self._InitPlatformIfNeeded() for x in range(0, _BROWSER_STARTUP_TRIES): try: # Note: we need to regenerate the browser startup arguments for each # browser startup attempt since the state of the startup arguments # may not be guaranteed the same each time # For example, see: crbug.com/865895#c17 startup_args = self.GetBrowserStartupArgs( self._browser_options) browser_backend = desktop_browser_backend.DesktopBrowserBackend( self._platform_backend, self._browser_options, self._browser_directory, self._profile_directory, self._local_executable, self._flash_path, self._is_content_shell, build_dir=self._build_dir) new_browser = browser.Browser(browser_backend, self._platform_backend, startup_args) browser_backend.SetDownloadBehavior('allow', self._download_directory, 30) return new_browser except Exception: # pylint: disable=broad-except retry = x < _BROWSER_STARTUP_TRIES - 1 retry_message = 'retrying' if retry else 'giving up' logging.warn('Browser creation failed (attempt %d of %d), %s.', (x + 1), _BROWSER_STARTUP_TRIES, retry_message) if retry: # Reset the environment to prevent leftovers in the profile # directory from influencing the next try. # CleanUpEnvironment sets browser_options to None, # so we must save them. saved_browser_options = self._browser_options self.CleanUpEnvironment() self.SetUpEnvironment(saved_browser_options) else: raise
def Create(self): if self._flash_path and not os.path.exists(self._flash_path): logging.warning( 'Could not find Flash at %s. Continuing without Flash.\n' 'To run with Flash, check it out via http://go/read-src-internal', self._flash_path) self._flash_path = None self._InitPlatformIfNeeded() startup_args = self.GetBrowserStartupArgs(self._browser_options) num_retries = 3 for x in range(0, num_retries): returned_browser = None try: returned_browser = None browser_backend = desktop_browser_backend.DesktopBrowserBackend( self._platform_backend, self._browser_options, self._browser_directory, self._profile_directory, self._local_executable, self._flash_path, self._is_content_shell) self._ClearCachesOnStart() returned_browser = browser.Browser(browser_backend, self._platform_backend, startup_args) if self._browser_options.assert_gpu_compositing: gpu_compositing_checker.AssertGpuCompositingEnabled( returned_browser.GetSystemInfo()) return returned_browser # Do not retry if gpu assertion failure is raised. except gpu_compositing_checker.GpuCompositingAssertionFailure: raise except Exception: # pylint: disable=broad-except report = 'Browser creation failed (attempt %d of %d)' % ( (x + 1), num_retries) if x < num_retries - 1: report += ', retrying' logging.warning(report) # Attempt to clean up things left over from the failed browser startup. try: if returned_browser: returned_browser.Close() except Exception: # pylint: disable=broad-except pass # Re-raise the exception the last time through. if x == num_retries - 1: raise
def Create(self, clear_caches=False): # TODO(crbug.com/811244): Remove when callers no longer use this option. assert not clear_caches, 'Option no longer supported, see: crbug.com/811244' if self._flash_path and not os.path.exists(self._flash_path): logging.warning( 'Could not find Flash at %s. Continuing without Flash.\n' 'To run with Flash, check it out via http://go/read-src-internal', self._flash_path) self._flash_path = None self._InitPlatformIfNeeded() num_retries = 3 for x in range(0, num_retries): returned_browser = None try: # Note: we need to regenerate the browser startup arguments for each # browser startup attempt since the state of the startup arguments # may not be guaranteed the same each time # For example, see: crbug.com/865895#c17 startup_args = self.GetBrowserStartupArgs(self._browser_options) returned_browser = None browser_backend = desktop_browser_backend.DesktopBrowserBackend( self._platform_backend, self._browser_options, self._browser_directory, self._profile_directory, self._local_executable, self._flash_path, self._is_content_shell) return browser.Browser( browser_backend, self._platform_backend, startup_args) except Exception: # pylint: disable=broad-except report = 'Browser creation failed (attempt %d of %d)' % ( (x + 1), num_retries) if x < num_retries - 1: report += ', retrying' logging.warning(report) # Attempt to clean up things left over from the failed browser startup. try: if returned_browser: returned_browser.DumpStateUponFailure() returned_browser.Close() except Exception: # pylint: disable=broad-except pass # Re-raise the exception the last time through. if x == num_retries - 1: raise
def Create(self, finder_options): if self._flash_path and not os.path.exists(self._flash_path): logging.warning( 'Could not find Flash at %s. Continuing without Flash.\n' 'To run with Flash, check it out via http://go/read-src-internal', self._flash_path) self._flash_path = None self._InitPlatformIfNeeded() browser_backend = desktop_browser_backend.DesktopBrowserBackend( self._platform_backend, finder_options.browser_options, self._local_executable, self._flash_path, self._is_content_shell, self._browser_directory) return browser.Browser(browser_backend, self._platform_backend, self._credentials_path)
def Create(self, finder_options): if self._flash_path and not os.path.exists(self._flash_path): logging.warning( 'Could not find Flash at %s. Continuing without Flash.\n' 'To run with Flash, check it out via http://go/read-src-internal', self._flash_path) self._flash_path = None self._InitPlatformIfNeeded() num_retries = 3 for x in range(0, num_retries): returned_browser = None try: returned_browser = None browser_options = finder_options.browser_options browser_backend = desktop_browser_backend.DesktopBrowserBackend( self._platform_backend, browser_options, self._local_executable, self._flash_path, self._is_content_shell, self._browser_directory) browser_backend.ClearCaches() returned_browser = browser.Browser(browser_backend, self._platform_backend) return returned_browser except Exception: # pylint: disable=broad-except report = 'Browser creation failed (attempt %d of %d)' % ( (x + 1), num_retries) if x < num_retries - 1: report += ', retrying' logging.warning(report) # Attempt to clean up things left over from the failed browser startup. try: if returned_browser: returned_browser.Close() except Exception: # pylint: disable=broad-except pass # Re-raise the exception the last time through. if x == num_retries - 1: raise
def Create(self): if self._flash_path and not os.path.exists(self._flash_path): logging.warning( 'Could not find Flash at %s. Continuing without Flash.\n' 'To run with Flash, check it out via http://go/read-src-internal', self._flash_path) self._flash_path = None self._InitPlatformIfNeeded() # TODO(crbug.com/944343): Fix these retries. They leave the user-data-dir # around, which contains DevToolsActivePort file. num_retries = 3 for x in range(0, num_retries): try: # Note: we need to regenerate the browser startup arguments for each # browser startup attempt since the state of the startup arguments # may not be guaranteed the same each time # For example, see: crbug.com/865895#c17 startup_args = self.GetBrowserStartupArgs( self._browser_options) browser_backend = desktop_browser_backend.DesktopBrowserBackend( self._platform_backend, self._browser_options, self._browser_directory, self._profile_directory, self._local_executable, self._flash_path, self._is_content_shell) return browser.Browser(browser_backend, self._platform_backend, startup_args) except Exception: # pylint: disable=broad-except report = 'Browser creation failed (attempt %d of %d)' % ( (x + 1), num_retries) if x < num_retries - 1: report += ', retrying' logging.warning(report) # Re-raise the exception the last time through. if x == num_retries - 1: raise