Skip to content

Intermittent Nullpointer within Resolver.lookup when using @LazyInjected #184

@howru42

Description

@howru42

@LazyInjected sometimes causing Null Pointer Exceptions in Resolver v1.2.1

Description:

We are experiencing intermittent crashes in our application related to @LazyInjected properties resulting in Null Pointer Exceptions (NPEs). The issue occurs on the main thread and appears to be happening during the resolution process itself.
We are using Resolver version 1.2.1.

The crash happens when accessing the wrappedValue.getter of the @LazyInjected property, which suggests that the underlying dependency is not being initialized correctly or is being accessed in an invalid state under specific circumstances.

Crashlytics Thread Report:

Crashed: com.apple.main-thread
0 Resolver 0x54a0 Resolver.lookup(:name:) + 261 (Resolver.swift:261)
1 Resolver 0x524c Resolver.resolve
(:name:args:) + 218 (Resolver.swift:218)
2 Resolver 0x56b8 static Resolver.resolve(_:name:args:) + 200
3 Resolver 0x9284 LazyInjected.wrappedValue.getter + 740 (Resolver.swift:740)
4 TestAuth 0x12bc4c LoginViewModel.isBiometricSupported.getter + 104 (LoginViewModel.swift:104)
5 TestAuth 0x1267f4 LoginViewController.loadView() + 123 (LoginViewController.swift:123)
... (rest of the trace)

Relevant Code Snippet (from our app):

The crash is triggered when accessing isBiometricSupported within LoginViewModel or LoginViewController.swift

class LoginViewModel {
    // Assuming this is the property causing the crash
    @LazyInjected var biometricService: BiometricServiceProtocol 
    
    var isBiometricSupported: Bool {
        // Accessing the injected property causes the crash sometimes
        return biometricService.isAvailable 
    }
    // ...
}

Steps to Reproduce:

The crashes are intermittent and non-deterministic, making them difficult to reproduce on a development machine. They occur rarely in production environments across various devices and iOS versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions