Skip to content

Avoid AppDatabase.getInstance to be use outside of Hilt #5702

@TimoPtr

Description

@TimoPtr

AppDatabase.getInstance is thread safe with a synchronized block to avoid having multiple thread creating multiple instance of the database and overriding the instance static attribute.

The issue is that if multiple actor call getInstance all of them are going to be blocked by the synchronized block if the instance is not yet created and it leads to ANR.

We should avoid this and only have Hilt invoking this function. It means a huge work to adapt the codebase to always rely on Hilt to get the database never using getInstance, by doing so we ensure we won't ever have an ANR again on this function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions