Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. PyQt5 WebEngineView If it has cookies, it crashes
QtWS25 Last Chance

PyQt5 WebEngineView If it has cookies, it crashes

Scheduled Pinned Locked Moved Solved QtWebEngine
6 Posts 3 Posters 705 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suundumused
    wrote on last edited by
    #1

    Every time I start the app, it creates cache and cookies folders, but if I close the application and open it again, it loads the cookies and after about 5 seconds it crashes and closes without errors in the log, until then I have a code that forces it to delete the cookies and cache folders. But it's not what I wanted, I wanted the user to be able to keep cookies without any problems.

    Deleting cookies and cache:

    try:                
            if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Cache')):
                shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Cache')))
        except:
             pass
           
        try:                
             if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Storage')):
                 shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Storage')))
        except:
             pass
        try:                
            if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropCache')):
                shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropCache')))
        except:
             pass           
        try:                
            if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropStorage')):
                shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropStorage')))
        except:
             pass
    

    Construction of web engine view:

        self.browser = QWebEngineView()
    

    Creating all deleted folders...
    ........

        profile = QWebEngineProfile("my_profile", self.browser)
        
        profile.defaultProfile().setPersistentCookiesPolicy(QWebEngineProfile.NoPersistentCookies)
        
        profile.defaultProfile().setCachePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropCache'))
        profile.defaultProfile().setPersistentStoragePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropStorage'))
        profile.defaultProfile().setDownloadPath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Downloads'))
    
        profile.setCachePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Cache'))
        profile.setPersistentStoragePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Storage'))
        profile.setDownloadPath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Downloads'))
        
        webpage = QWebEnginePage(profile, self.browser)
        webpage.settings().setAttribute(QWebEngineSettings.PlaybackRequiresUserGesture, True)
    
        self.show()
    

    " profile.defaultProfile().setPersistentCookiesPolicy(QWebEngineProfile.NoPersistentCookies) " I tried setting this value to ForcePersistentCookies or removing it, it didn't change anything.

    The entire code of this software is in that repository

    jsulmJ 1 Reply Last reply
    0
    • S Offline
      S Offline
      Suundumused
      wrote on last edited by
      #6

      After all, I configured everything wrong, disregard my code above, i have posted in this Topic the solution.

      1 Reply Last reply
      0
      • S Suundumused

        Every time I start the app, it creates cache and cookies folders, but if I close the application and open it again, it loads the cookies and after about 5 seconds it crashes and closes without errors in the log, until then I have a code that forces it to delete the cookies and cache folders. But it's not what I wanted, I wanted the user to be able to keep cookies without any problems.

        Deleting cookies and cache:

        try:                
                if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Cache')):
                    shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Cache')))
            except:
                 pass
               
            try:                
                 if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Storage')):
                     shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Storage')))
            except:
                 pass
            try:                
                if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropCache')):
                    shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropCache')))
            except:
                 pass           
            try:                
                if os.path.exists(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropStorage')):
                    shutil.rmtree((str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropStorage')))
            except:
                 pass
        

        Construction of web engine view:

            self.browser = QWebEngineView()
        

        Creating all deleted folders...
        ........

            profile = QWebEngineProfile("my_profile", self.browser)
            
            profile.defaultProfile().setPersistentCookiesPolicy(QWebEngineProfile.NoPersistentCookies)
            
            profile.defaultProfile().setCachePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropCache'))
            profile.defaultProfile().setPersistentStoragePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\DropStorage'))
            profile.defaultProfile().setDownloadPath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Downloads'))
        
            profile.setCachePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Cache'))
            profile.setPersistentStoragePath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Documents\WebWidget\Storage'))
            profile.setDownloadPath(str(str(os.path.expanduser(os.getenv('USERPROFILE'))) + r'\Downloads'))
            
            webpage = QWebEnginePage(profile, self.browser)
            webpage.settings().setAttribute(QWebEngineSettings.PlaybackRequiresUserGesture, True)
        
            self.show()
        

        " profile.defaultProfile().setPersistentCookiesPolicy(QWebEngineProfile.NoPersistentCookies) " I tried setting this value to ForcePersistentCookies or removing it, it didn't change anything.

        The entire code of this software is in that repository

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Suundumused said in PyQt5 WebEngineView If it has cookies, it crashes:

        without errors in the log

        Run through debugger to see what happens

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Suundumused said in PyQt5 WebEngineView If it has cookies, it crashes:

          without errors in the log

          Run through debugger to see what happens

          S Offline
          S Offline
          Suundumused
          wrote on last edited by Suundumused
          #3

          @jsulm

          [2300:4272:0126/102900.323:ERROR:cache_util_win.cc(20)] Unable to move the cache: 5
          [2300:4272:0126/102900.323:ERROR:cache_util.cc(134)] Unable to move cache folder 
          [2300:4272:0126/102900.323:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
          
          Release of profile requested but WebEnginePage still not deleted. Expect troubles !
          
          JonBJ 1 Reply Last reply
          0
          • S Suundumused

            @jsulm

            [2300:4272:0126/102900.323:ERROR:cache_util_win.cc(20)] Unable to move the cache: 5
            [2300:4272:0126/102900.323:ERROR:cache_util.cc(134)] Unable to move cache folder 
            [2300:4272:0126/102900.323:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
            
            Release of profile requested but WebEnginePage still not deleted. Expect troubles !
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @Suundumused
            I would suggest this will be a chromium issue. If you Google for, say, ERROR:cache_util_win.cc you will find quite a few posts to look through matching your error messages.

            S 1 Reply Last reply
            1
            • JonBJ JonB

              @Suundumused
              I would suggest this will be a chromium issue. If you Google for, say, ERROR:cache_util_win.cc you will find quite a few posts to look through matching your error messages.

              S Offline
              S Offline
              Suundumused
              wrote on last edited by
              #5

              @JonB I used Jupyter in debug, it just returned unknown crash error in the log, ): I'm using Version: 5.15.9, Could a downgrade fix it?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Suundumused
                wrote on last edited by
                #6

                After all, I configured everything wrong, disregard my code above, i have posted in this Topic the solution.

                1 Reply Last reply
                0
                • S Suundumused has marked this topic as solved on

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved