
Infinite loop in macOS Night Shift in the summer near the Arctic Circle - guessmyname
https://twitter.com/AustinJ/status/1144655793612107778
======
jedberg
Deep in the twitter replies:

> Now, is this a corner case, an edge case or a boundary case? And does the
> answer depend on whether you are a flat-earther or not?

That was too funny.

~~~
zaszrespawned
Personally I believe that earth is flat disk carried by 4 elephants, which are
standing on the back of a giant turtle

~~~
mirimir
Sure, but that turtle is carried by four "elephants, which are standing on the
back of a giant turtle". And that turtle ...

~~~
TeffenEllis
I really wish people would find true enlightenment. It's obvious a turtle in
space wouldn't need anything underneath -- because turtles swim!

~~~
mirimir
Sure. But really, it's all illusion. So better just unask the question.

------
fishywang
Semi-related, I noticed that Google handled this case in the weather part
during my last year's summer visit of Utqiagvik, AK:
[https://twitter.com/fishywang/status/1013931269363658754](https://twitter.com/fishywang/status/1013931269363658754)

------
supernova87a
Perhaps it's because they implemented the "Sunrise equation" naively, which
becomes indeterminate for high latitudes when the Sun is close to the maximum?

[https://en.wikipedia.org/wiki/Sunrise_equation](https://en.wikipedia.org/wiki/Sunrise_equation)

cos(\Omega) = - tan(\phi) x tan(\delta)

Where \Omega = hour angle (sunrise, sunset offset from noon), \phi = latitude,
\delta = sun declination.

Clearly if the right hand side gets big enough (>1), this doesn't work.

~~~
pcwalton
Never knew about that equation! That's cool.

Angles are always such a pain. In my experience it's worth applying
trigonometric identities and working in terms of unit vectors, sines, and
cosines instead of using angles directly. In this case angles seem
unavoidable, though: acos(tan(x)*tan(y)) doesn't simplify to anything useful.

~~~
ccrush
It's omega = acos( - tan(x) * tan(y)), not that that makes much of a
difference.

------
lb1lf
My old Garmin eTrek something-or-the-other had a feature which would compute
local sunrise and -set.

It threw a fit and rebooted when I asked it for sunset while at 78 degrees
north in June.

------
adim86
This is a beautiful example of the importance of diversity on a team. I have
no idea how diverse the team is and I am not speaking of racial or sex
diversity... this is the core of the discussion, having people with varying
life experiences prevent obvious bugs like this or innovative ideas that no
one person could think about. This is a fun bug

~~~
chrstphrknwtn
Whilst that’s true, I think it’s also a good example of how shortsighted most
attempts at diversity are; in this case a Scandinavian would perhaps have the
“diverse experience” to preempt a naïve implementation of a sunrise fiction,
however diversity seems to always be about race or sex or identity, which
seems to miss the point somewhat.

Edit: Which is to say that a male with fair hair and skin and a university
education wouldn’t qualify as diverse in most contemporary conceptions of
diverse, despite a likely underlying diversity of culture and experience.

~~~
carlmr
Apple's diversity manager said something to that effect, and then she was made
to apologize and leave.

So, yes, diversity of experience is important, and no, that's not what is
accepted as diversity in modern corporate culture.

[https://www.telegraph.co.uk/news/2017/10/17/apples-head-
dive...](https://www.telegraph.co.uk/news/2017/10/17/apples-head-diversity-
apologises-saying-group-12-white-men-can/)

~~~
chrstphrknwtn
That episode proves the point I think. It seems to demonstrate perfectly how
the only diversity that counts is race and sex. The article literally
concludes with a breakdown of Apple’s workforce by ethnicity and sex.

------
cstross
The perils of living on a spinning oblate sphere strike again!

Software would be so much simpler on a ringworld ...

~~~
fortran77
This is due mainly to our tilt, not our sphere-ness

~~~
dougmwne
On a spherical world with no tilt, what time is sunrise at the north pole?

~~~
pault
Approximately four billion years ago.

~~~
stestagg
Don’t you mean 6,000 years?

------
DonHopkins
Has anyone ever determined how many times you have to drive around Infinite
Loop before Apple Security calls the police on you?

~~~
ashton314
I had a friend who once drove around a traffic circle as many times as he
could. He got up to 39 times before a police officer pulled him over.

Does anybody know if there is a law on that?

~~~
jedberg
Depends on the state/country, but most have rule that you can't go around more
than once. In fact, most places I've seen in the US you can't even go more
than 3/4s around (although I'm not sure if that's a law or just a posted
suggestion).

~~~
mantap
What the hell? What if you miss your turning or want to do a u-turn? Going
around more than once is a perfectly reasonable thing to do.

~~~
cheerlessbog
What if it's a magic roundabout? [1]

[1]
[https://en.m.wikipedia.org/wiki/Magic_Roundabout_(Swindon)](https://en.m.wikipedia.org/wiki/Magic_Roundabout_\(Swindon\))

~~~
DonHopkins
It looks like a pinball machine with bumpers and flippers!

------
cold_fact
reminds of the Computerphile Tom Scott video "The Problem with Time &
Timezones"

[https://www.youtube.com/watch?v=-5wpm-
gesOY](https://www.youtube.com/watch?v=-5wpm-gesOY)

and why I will never implement datetime myself

~~~
a3n
Nobody ever got fired for using the provided datetime.

~~~
robertAngst
What is the standard for using datetime libraries?

Use the one that comes with each language, or use some UTC library?

------
gberger
'Falsehoods programmers believe about time: \- Every day has a sunrise and a
sunset'

~~~
adtac
Time is hard: [https://zachholman.com/talk/utc-is-enough-for-everyone-
right](https://zachholman.com/talk/utc-is-enough-for-everyone-right)

This is all because of the fact that we're trying to represent the time taken
by the earth (an arbitrary planet that has no impact on the universe
whatsoever) to revolve around the sun (an arbitrary star) in terms of the
amount of time the earth takes to rotate around itself. These two obviously
unrelated things are somehow merged into to create an unsolvable clusterfuck.
To make matters worse, let's sprinkle some politics...

~~~
icxa
> (an arbitrary planet that has no impact on the universe whatsoever)

What do you call this type of worldview where you just view everything as
completely meaningless or devoid of any value? Is it really straight up
Narcism? I mean my god no wonder this is one of the most depressed generations
on record.

Apologies for the off-topic comment, I just felt compelled to post this. We
are the most meaningful, most important things in the universe until we know
or learn otherwise. We are the most intelligent, most accomplished life forms
in our known existence. Viewing it as arbitrary might be "technically true"
but then again what do we know? What if we are it? It is just as plausible as
the other view: that we are just on a billion year course for the eventual
heat death of the universe and the end of existence all together.

Treat yourselves as special, you are. Treat others that way too. You'll also
be a lot happier. Sorry for the platitudes.

~~~
chendragon
If I remember correctly the word you're looking for is nihilism.

~~~
laughinghan
Ironically, viewing yourself as the most meaningful, important, intelligent,
accomplished thing in the universe sounds a lot like narcissism.

~~~
delinka
When your "universe" is the size of a solar system with a single life-
supporting planet, what other conclusion could possibly be met?

If you're the only one in a talent contest, you're the best ... and the worst.

------
fest
I sometimes wonder how many bugs are lurking in systems using GPS for
navigation at 180th meridian (where longitude goes from 180 to -180).

~~~
danaliv
IIRC there was a bug in an early version of a certain fighter jet where it
would go inverted when crossing the equator. Oops.

~~~
macintux
Urban legend or so it would appear.

[https://www.ar15.com/forums/general/Urban_legend_about_F16__...](https://www.ar15.com/forums/general/Urban_legend_about_F16___true_or_bunk_/5-154222/)?

~~~
danaliv
Oh, bummer. That would’ve been a fun case study if it had been true.

------
JetSpiegel
The Suntimes Android app (its on F-Droid) correctly reports None for such high
latitudes.

------
randartie
Am I the only person who is impressed with this person's debugging skill?

~~~
uxp
Not really.

All he's shown is a behavior (high CPU) and is equating it with the latitude
he's at. When he turns off Night Shift, the daemon process for the feature
stops consuming as much CPU, from what I gathered. Nowhere does he provide
evidence that there is an infinite loop calculating the sunrise/sunset.

And I really don't want to be a stereotypical poster by simply degrading what
he did, so I will give credit to him for knowing where to look and making a
hypothesis that is not wrong. He's perfectly on point to _begin_ a debugging
process, but I can't see he's found a bug. He's found an unexpected or
undesired behavior. I certainly would consider this story/tweet as a huge plus
if he were being interviewed by me for an engineering position, but it appears
he's already well above my pay grade anyways.

~~~
IAmEveryone
You’re splitting hairs and failing at it. They have clearly found a “bug” if
Night Shift is consuming 100% CPU without end, even if their hypothesis for
the reason might be wrong.

~~~
maxheadroom
> _They have clearly found a “bug”..._

This depends on your definition of "bug". I think, in the classical sense, a
bug is something that you understand both the cause and the resultant
undesired behaviour and, as of consequence, you can reproduce the chain of
events.

Given that definition, I would be disinclined to agree with calling it a
"bug".

 _However_ , I would also like to point out that we're getting so nuanced in
terms that we're, quite literally, dropping the notion of lauding the attempts
of the OP to go down the road of wanting to deduce the problem, themselves.

~~~
patrick5415
I disagree. If you have to understand the cause of undersires behaivor before
a bug can be said to exist, then debugging is a prerequisite to a bug
existing.

If I write a program that computes 2+2 and it tells me the answer is 5, that’s
a bug. Why is irrelevant until I want to fix it.

------
ufo
Does anyone know how other similar programs behave in these latitudes? For
example, f.lux, GNOME's night light, or Redshift?

------
mrbill
Reminds me of an early release build of Win95. It would properly set time back
an hour for Daylight Saving Time, but not set a flag that it had been done, so
it would do it over, and over, and over...

------
dekhn
now that's a great test case that could easily be tested using mocks.

~~~
bdamm
My favorite part of "To the Moon and Back" is when the NASA administrator is
explaining to Congress that the three astronauts on board Apollo 1 died
because "We weren't creative enough to imagine this could happen."

------
simongr3dal
Would this be a bug in the Night Shift feature, or something more fundamental,
i.e. something in Apple's Foundation library?

------
SergeAx
I wonder if Apple shares that code in iOS too?

~~~
saagarjha
CoreBrightness is similar across the platforms.

~~~
sudhirj
Maybe, but I don’t think there’s a CoreSunrise or CoreSunset. The problem
isn’t in setting the brightness or colour tone, it’s calculation when to
switch between them.

~~~
saagarjha
iOS and macOS share GeoServices, which performs the actual calculation of
sunrise/sunset times (among other things).

------
Zekio
hmm I wonder if it also applies in the other direction where the sun doesn't
rise for a part of the year as well

~~~
sovande
> where the sun doesn't rise for a part of the year as well

That would be the same place a few months from now. This is strange though,
it's not like this guy is the first above the polar circle using a Mac. I
suspect it must somehow be related to him being a tourist with a different
region and timezone settings or maybe the location services got confused.

------
bsimpson
The capitalization in the title made me originally parse this as about Apple's
former headquarters
([https://en.wikipedia.org/wiki/Apple_Campus](https://en.wikipedia.org/wiki/Apple_Campus)).

~~~
cmelbye
The sun never sets on the Apple Empire.

------
pier25
It happens in the best of families

