Skip to content

Context() and page caching (and also some inconsistency) #1206

@jammer312

Description

@jammer312

Rod Version: v0.116.2

If you set a context on a browser and then call Pages(), it'll set page contexts to browser context (with extra cancel (which stops being relevant the moment you call Context() on a page)) and also set browser pointer to itself, which is fine for that call, but then it'll cache these values. If you later set another context and call Pages() again, all old pages will return with old context (possibly cancelled already).
Cloning cached pages and setting context to current browser context doesn't solve it completely for two reasons:

  • Page.Info(), Page.Activate() and Page.TriggerFavicon() disregard page context and use browser context instead (and cached pages have old browser pointers with old context) (but this is trivial to fix, other methods already use p.browser.Context(p.ctx))
  • Pages have pointers to input devices which have mutexes and state, and can't be cloned as is (probably can be decoupled so mutex and state are in one place and pointer to a page is in the other, and only the pointer part is cloned). And also there's root page and element for iframe, which might cause similar issues too.

Imo explicitly passing context to all blocking functions is better than including context in objects (much more predictable and not as convoluted).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions