From U.S. anger over inaction on North Korea to a festering border dispute with India and the ailing Chinese Nobel laureate Liu Xiaobo, last week's G20 summit was strewn with minefields for China's President Xi Jinping.
By chance or by strategy, Xi and his officials picked their way through unscathed.
Beijing is ultra-sensitive about Xi's image and ensuring he gets the respect it sees as his due as leader of an emerging superpower, especially when travelling to Western countries where it cannot so tightly control the public narrative.
Diplomatic sources in Beijing, speaking ahead of Xi's trip to the G20 gathering in the German city of Hamburg, said Chinese officials had in private expressed nervousness that he could be asked awkward questions about North Korea, or the cancer-struck Liu, jailed for 11 years in 2009 for "inciting subversion of state power".
In the end it was U.S. President Donald Trump's meeting with Russian President Vladimir Putin, amid accusations Russia interfered in the U.S. election, and Trump's refusal to return to the Paris climate agreement that dominated the limelight.
Xi, by contrast, avoided controversy in his bilateral meetings and reaffirmed China's commitment to the Paris deal and to an open global economy, in what the official China Daily called the "burnishing of (his) reputation".
"Nobody talked about the South China Sea. No one talked about trade. Everyone was happy with Xi. I think he played this well," said Ulrich Speck, senior fellow at the Elcano Royal Institute in Brussels.
"All eyes were on Trump and Putin. But the fact that there was no U.S.-China clash was at least as important. Xi stayed out of the alpha-male fight. China presented itself as a partner to Europe."
Chinese Foreign Minister Wang Yi said Xi "made it clear that the G20 should adhere to taking the path of open development and mutual benefit leading to all-win results, support a multilateral trade mechanism, and promote international trade and investment".
"China was in a good place at G20, with reasonable policies," said Jin Canrong of the School of International Studies at the Renmin University of China, who has advised the government on diplomatic matters.
"So President Xi was comfortable and positive there."
Potentially the biggest test was Xi's meeting with Trump, who in the run-up to Hamburg had voiced frustration over China's inability to rein in its troublesome erstwhile ally, North Korea.
In the event, Trump returned to the conciliatory tone struck at their first meeting in April, telling the Chinese leader it was "an honour to have you as a friend" and he appreciated actions Xi had already taken to try to dissuade North Korea from pursuing nuclear weapons.
Influential Chinese state-run tabloid the Global Times said in an editorial on Monday that the Xi-Trump meeting had defied "the naysayers in the West".
"Beijing and Washington saw friction on issues including Taiwan and the South China Sea ahead of the meeting, and there was speculation from Western public opinion that the China-U.S. 'honeymoon' had come to an end.
But the Xi-Trump meeting repudiates such speculation," the paper said.
Speaking to reporters later on Air Force One, U.S. Treasury Secretary Steven Mnuchin said the Trump-Xi meeting lasted more than an hour-and-a-half, and would have gone on longer had they not had to leave for other engagements.
Ruan Zongze, a former Chinese diplomat now with the China Institute of International Studies, a think-tank affiliated with the Foreign Ministry, said Xi was much more upbeat than when he spoke to Trump a few days ahead of G20 and mentioned certain unnamed "negative factors" in their relationship.
"Even on trade Trump underscored that he wants cooperation," Ruan said.
China's biggest concern had been U.S. policy towards self-ruled Taiwan, after the Trump administration approved a $1.42 billion arms package for Taiwan, claimed by China as its own.
Neither government mentioned Taiwan in their respective accounts of their G20 meeting.
Chinese officials were at pains to point out their good relations with the new administration in Washington.
Vice Finance Minister Zhu Guangyao told reporters in Hamburg that the Chinese and U.S. teams dealing the bilateral financial relationship clearly understood that both would be hurt by fighting with each other.
"Our strength is communicating every morning and every evening. This is unprecedented," Zhu said.
On India, where China has over the past few weeks accused New Delhi of provocation by sending troops across the border in a disputed region, Xi avoided drama by not having a formal bilateral meeting with Indian Prime Minister Narendra Modi, though India's foreign ministry said they did speak.
Even on Liu Xiaobo, Xi avoided being put on the spot, with China on Saturday allowing a U.S. and German doctor to meet him at his hospital in northeastern China.
Still, the faultlines remain in the tricky China-United States relationship.
China may respond more assertively if, for example, more Chinese entities are sanctioned by the United States over North Korea or Trump raises barriers to Chinese goods as he has frequently threatened, said a senior Beijing-based Western diplomat.
"China has been restrained so far in reacting to Trump, but that is unlikely to last," said the diplomat, speaking on condition of anonymity. "Things are gearing up to be a summer of drama between China and the United States." - Reuters