The opening film of the 2017 Cannes Film Festival is several movies at once, some more successful than others.

Within its first half hour, “Ismael’s Ghosts” weaves together espionage, melodrama, supernatural hauntings, and a filmmaker’s creative crisis. It’s the most ambitious movie to date from French director Arnaud Desplechin, whose ensemble dramas “A Christmas Tale” and “My Golden Years” also dealt with characters coping with their troubled pasts. This time, it’s a wild hodgepodge of genres that often risk collapsing on top of each other. At its best, the movie is a freewheeling gambit, hurtling in multiple directions at once, and it’s thrilling to watch Desplechin try juggle them all.

“Ismael’s Ghosts” within the confines of a movie imagined by its main character: a dense, labyrinthine spy story involving the experiences of young recruit Ivan (Louie Garrel) who’s services straight out of school. Minutes into that setup, Desplechin pulls out to reveal the world of disheveled writer-director Ismael (Mathieu Amalric), a rugged, hard-drinking artist buried in the process of writing a screenplay he can’t fully sort out. Abandoned without explanation by his wife 20 years ago and having presumed her dead, he still cares for her ailing father (Laszlo Szabo) and has launched a promising new romance with astronomer Sylvia (Charlotte Gainsbourg).

But when Ismael takes Sylvia to his beach house one weekend, the past comes back to haunt him in more ways than one: While enjoying the waves one morning, Sylvia is confronted by Carlotta (Marion Cotillard), Ismael’s supposedly dead ex.

READ MORE: ‘Ismaël’s Ghost’ Clips: Marion Cotillard Bops Along to Bob Dylan’s ‘It Ain’t Me Babe’ — Watch

The second act is an intriguing showcase for all three actors, as a baffled Ismael confronts Carlotta about her extensive disappearance and Sylvia attempts to sort out how these circumstances might affect her future with Ismael. On its own terms, this setup would stand on steady ground as a self-contained movie, with a sturdy conflict rooted in the mounting suspicions and conflicting desires of a love triangle that has no easy solution. It’s a small gem of interlocking romances before rushing on to the next thing.

Cotillard is particularly enthralling as a melancholic bundle of mysteries eager to return to a world still haunted by the trauma of her departure; her interactions with Gainsbourg are fascinating, ambiguous stabs at bonding under impossible circumstances, most notably when she attempts to placate the other woman in Ismael’s life with a carefree dance to Bob Dylan’s “Baby, It Ain’t Me” on the porch as a deadpan Sylvia looks on. (It’s a blunt choice that Cotillard’s lively performance makes palatable.)

Gainsbourg does a solid job of exuding her frustrations stemming from Carlotta’s sudden arrival, but she’s sidelined by Ismael’s prominence in the narrative and winds up subservient to his existence. Fortunately, Desplechin regular Amalric is at the height of his powers as a frumpy, wide-eyed romantic slave to his passions and so lost in thought that the movie seems to exist at the whims of his restless mind.

Once the beach house dynamic falls apart, “Ismael’s Ghosts” heads into a less enthralling pity party as Ismael attempts to heal the various rifts in his life with mixed results. Finally, the story ventures into comedic territory as he makes a last-ditch effort to save his movie. This has been familiar territory ever since Fellini’s “8 1/2,” but Desplechin’s Ismael is not nearly as engaging a character as Marcello Mastroianni’s Guido Anselmi. Here, the movie suffers whenever it suggests there’s a real author behind all the layers of storytelling crying for help.

Still, the movie retains an air of elegance: Gregoire Hetzel’s ominous score channels the spirit of Bernard Hermann and complements the echoes of “Vertigo” that creep into the plot, while the Irinia Lubtchansky’s slick images respond to the oscillating tones. As Desplechin flits between Ismael’s movie, his bumpy life story, and abrupt flashbacks, the movie feels like the shaggier, more boisterous second cousin to Spike Jonze’s “Adaptation,” its rough edges designed to mirror the main character’s fragmented inner life. When the movie crystallizes these loose themes, it retains an emotional clarity that draws the disparate pieces together. As Sylvia struggles to figure out if she can reintegrate into her old life, Carlotta tells her: “You exist for no one now.” That statement could apply to the entire cast.

READ MORE: The 2017 IndieWire Cannes Bible: Every Review, Interview and News Item Posted During the Festival

With so many audacious narrative ingredients on display, it’s unfortunate that the movie falls short of a satisfactory resolution. Instead, it heads into a series of overwrought showdowns that smooth out the various subplots in a tidy fashion. At one point, Ismael analogizes his project to the chaotic intentions of a Jackson Pollock canvas, with its hectic lines clarifying the painter’s vivid experiences. True enough, but this medium isn’t so kind to such a willfully messy approach, at least within the strictures of the narrative told here.

While it opens the 2017 Cannes Film Festival in a cut that runs just under two hours, Desplechin has reportedly prepared another version that runs 20 minutes longer and delves even deeper into Ismael’s past. Like the fictional director, Desplechin seems to be lost in the rabbit hole of his winding narrative and unable to complete its journey — and while “Ismael’s Ghosts” isn’t his best movie, it’s almost certainly his most personal statement on his tangled relationship to his art.

Grade: B-

“Ismael’s Ghosts” opened the 2017 Cannes Film Festival. Magnolia Pictures will release it in the U.S. later this year.

Stay on top of the latest breaking film and TV news! Sign up for our Email Newsletters here.

Sign Up: Stay on top of the latest breaking film and TV news! Sign up for our Email Newsletters here.