Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sometimes due to race condition PyBrowser reference lives forever #330

Closed
@cztomczak

Description

@cztomczak

A global reference to PyBrowser object is kept forever and this is causing the app to not quit its message loop after windows were closed, app is still running in background or when run from shell it does not return. This is easily reproduced in hello_world.py example:

  1. In google type "js alert"
  2. Browse to w3schools
  3. Try it - open popup
  4. Close popup
  5. Close main window

Now app will often not terminate its process. CEF message loop is still running. This happens because because len(g_pyBrowsers) > 0.

What happens in app is the following: a PyBrowser is created, then another PyBrowser is created, PyBrowser is closed, and then after browser was closed there is being called one of CEF handlers' callback which calls GetPyBrowser() - which creates PyBrowser again from scratch, as it was closed a moment ago. This reference now lives forever in g_pyBrowsers global list and is causing the message loop to never quit in OnBeforeClose. The solution would be to refactor GetPyBrowser to GetPyBrowserIfExists and return existing or create new PyBrowser only if it was not closed/destroyed previously. All usage of GetPyBrowser would need to be modified, so that it checks whether GetPyBrowserIfExists returned an actual object or a None value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions