Skip to content

[Bug]: MouseEvents have incorrect timestamps if machine is kept running 49+ days on mac #1587

@fyzix

Description

@fyzix

Detailed steps on how to reproduce the bug

In juce_NSViewComponentPeer_mac.mm there is this function getMouseTime:

    static int64 getMouseTime (NSEvent* e) noexcept
    {
        return (Time::currentTimeMillis() - Time::getMillisecondCounter())
                 + (int64) ([e timestamp] * 1000.0);
    }

This translates [NSEvent timestamp] values (time elapsed since system startup) into time elapsed since epoch (1970). However, Time::getMillisecondCounter() returns only the lower 32 bits of the milliseconds, so the subtraction here is not sufficient when more than 2^32 milliseconds ~ 49,7 days have passed since system startup - the translated timestamp will seem to be in the future from now by 49,7 days.

What is the expected behaviour?

I expect timestamps of OS mouse/key events not to be from the future when they arrive.

Operating systems

macOS

What versions of the operating systems?

Sequoia 15.5
macos 26.0.1

Architectures

Arm64/aarch64

Stacktrace

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct

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