I managed to find a workaround:
Call CGMainDisplayID(); before initalizing the filter. Tested both in Swift and Objective-c.
According to https://github.com/JXA-Cookbook/JXA-Cookbook/issues/27#issuecomment-277517668 its because Core Graphics is not initialized, and CGMainDisplayID does this.
I managed to find a workaround:
Call CGMainDisplayID(); before initalizing the filter. Tested both in Swift and Objective-c.
According to https://github.com/JXA-Cookbook/JXA-Cookbook/issues/27#issuecomment-277517668 its because Core Graphics is not initialized, and CGMainDisplayID does this.