The opening scene of “The King of Staten Island” sends a signal to anyone expecting raucous laughs: It depicts a suicide attempt.

The autobiographical comedy/drama stars Pete Davidson (“Saturday Night Live”) as Scott, a 24-year-old on New York City’s Staten Island who spends his time sketching tattoos, watching “SpongeBob SquarePants” and smoking weed in his mom’s (Marisa Tomei) basement. They’ve never talked about the death of Scott’s dad, and he is self-medicating with pot because, as he tells a friend, “I’m scared of myself and I don’t want to hurt you or anyone.”

Davidson has been candid about his mental health struggles, which are the main interest of “Staten Island.” Scott is unable to think past whatever he’s doing at the moment — standing lookout at a robbery, trying to ink a tattoo on a 9-year-old, blithely telling a friend who has loved him since grade school that he’s not into her — and that makes it hard for him to envision a future. He’s a funny guy who will joke about anything, but it’s clear his, and Davidson’s, humor comes from a really dark place.

Davidson gives “Staten Island” a unique edge, and although it’s not evident in his self-conscious “SNL” work, he’s a fine actor. Simultaneously laid-back and tightly wound, brash and baby-bird vulnerable, his Scott is an unpredictable and, I think, real character.

There’s a sense that he and his friends have suffered undefined psychic damage — they do live right across the harbor from where the World Trade Center once stood, and many of their parents are first responders — and that it has stuck them at about the same developmental age as that 9-year-old with the half-finished tattoo.

“The King of Staten Island” was directed and co-written by Judd Apatow and, for good and bad, it shares characteristics with his other movies, including “Knocked Up” and “Funny People”: It’s fascinated by how people make use of humor. Its stab at diversity feels perfunctory. It’s bro-y. It’s not hugely interested in women (although Tomei is excellent and Bel Powley, as Scott’s possible love interest, does a lot with a little). And it’s too long (137 minutes), with at least two subplots that go nowhere.

Even so, it’s distinctive work. The Staten Island setting is vivid, giving a sense of a small town almost literally in the huge shadow of Manhattan. The music of Kid Cudi, who also has been vocal about his mental health, is used smartly. And Apatow casts people who make a strong impression almost immediately, including Pamela Adlon as a sardonic neighbor and Maude Apatow (Judd’s daughter) as Scott’s sister, who is both relieved to escape her charged household by going off to college and worried about what will happen when she’s not there to keep the peace.

Fine acting helps give “Staten Island” a sense of a world that is familiar but that we have not seen in quite this way. The ending is overly eager to make us feel good about Scott’s future, wrapping things up much too neatly. Up to that point, though, there’s something beautiful about its messy insistence on the goodness and dignity of its title character, who is searching for a way to get out of his own head and, maybe, off that tiny island.