Actor Robin Williams was struggling with a brain disorder that was not immediately diagnosed, causing many of the bizarre symptoms that sapped him of his vitality and ultimately led him to take his own life.

That’s according to a new biography, Robin (Henry Holt & Co.) by Dave Itzkoff that’s out this month and details the final stages of Williams’s life.

Williams was initially diagnosed with Parkinson’s disease, but his behaviors in his last year were uncharacteristic of that malady, leading some to blame drugs or alcohol for his problem. Finally, a neuropathologist saw him and correctly diagnosed his affliction: diffuse Lewy body dementia. It is the second-most-common type of progressive dementia after Alzheimer’s disease, as protein deposits in the brain affect thinking, memory, emotions and body movements.

Williams began to cry uncontrollably, forget his lines, and suffer from a shuffling gait in his last days, according to the book. During the filming of Night at the Museum: Secret of the Tomb,” he reached a crisis point.

“He was sobbing in my arms at the end of every day. It was horrible. Horrible,” makeup artist Cheri Minns told author Itzkoff. “I said to his people, ‘I’m a makeup artist. I don’t have the capacity to deal with what’s happening to him.’ ”

When Minns suggested a return to stand-up comedy as a way out of his depression, Williams wouldn’t hear of it.  “He just cried and said, ‘I can’t, Cheri. I don’t know how anymore. I don’t know how to be funny.’ ”

After the failure of his short-lived 2013 television show The Crazy Ones, Williams’s health took a turn for the worse. He lost weight, his voice became tremulous, and he stooped.

Pam Dawber, his co-star from Mork & Mindy, had joined the cast of  The Crazy Ones in a last-ditch bid to to raise ratings. She noticed big changes in Williams.

“I would come home and say to my husband, ‘Something is wrong. He’s flat. He’s lost the spark. I don’t know what it is,’ ” Dawber says in the book.

Initally diagnosed with Parkinson’s disease – a diagnosis which said he still had “10 good years” to live – Williams tried to right his health ship, checking into a rehab center in hopes he could manage his illness.

Unfortunately, it was not a disease that could be overcome.