Skip to content

Race condition on startup: auto-connect fires before saved credentials are loaded #29

@kumaakh

Description

@kumaakh

Symptom

On ODM launch, cameras discovered via WS-Discovery fail to connect with saved credentials ~100% of the time. The same camera connects successfully if the user waits ~10 seconds and retries manually. This is 100% reproducible.

Hypothesis

There is a race condition between:

  1. WS-Discovery completing and triggering auto-connect with saved credentials
  2. The credential store finishing its async load from disk (DPAPI decryption)

When auto-connect fires before the credential store is ready, SetupUserNameToken either uses empty/default credentials or skips auth entirely. The camera rejects the attempt. By the time the user retries manually, the credential store has loaded and auth succeeds.

Supporting evidence from auth.log:

23:35:08.432 AuthView.Init: startup — version timestamp 2.2.252.15
23:35:31.577 btLogin_Click: name=admin storeCount=0

storeCount=0 at the time of login click indicates the credential store was not populated at connection time.

Required investigation

Add diagnostic logging at these points to confirm the race:

  1. Credential store load: log when DPAPI decryption starts and completes, and how many credentials were loaded
  2. Auto-connect trigger: log the exact timestamp when discovery triggers auto-connect and what credentials (if any) are available at that moment — specifically log storeCount at the point SetupUserNameToken is called during auto-connect
  3. SetupUserNameToken: already logs username — add log of whether credentials came from store vs. empty/anonymous
  4. Retry path: log when the user manually reconnects and what storeCount is at that point

Expected fix (after logging confirms the race)

Delay auto-connect until the credential store signals it is ready, OR queue auto-connect attempts and retry with credentials once they are available.

Priority

High — this makes ODM unusable on startup for cameras with saved credentials.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions