Skip to content

Resource.read() and Publication.positions are not safe to be called from the main thread #77

@jerome65536

Description

@jerome65536

Deadlock in main thread due to EPUBNavigatorViewController.viewDidLoad calling Resource.read via publication.positions with a DefaultHTTPClient-based Fetcher.

Since Resource.read blocks while waiting for a result, and the result can't be processed while the main thread is blocked, this freezes the whole app.

A workaround is to cache the result by calling let _ = publication.positions from a background thread before creating the EPUBNavigatorViewController, presumably preventing later calls of publication.positions from calling Resource.read.

Main thread callstack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions