Shanghai, China - A decade ago China produced 121 males for every 100 females. It was a frightening figure that officials could not ignore - the natural sex ratio being 105 boys to every 100 girls.

Worrying visions of a dystopian society overrun by tens of millions single Chinese men led to a government crackdown on illegal gender tests, selective abortions, and an eventual loosening of its one-child policy.

While the gender gap has decreased in recent years, now standing at almost 116 boys to every 100 girls, there are signs more needs to be done to tackle the problem.

In a country where the family name is carried down the patrilineal line, and male heirs are perceived to offer families the greatest social security, there is a well-known preference for sons over daughters.

China tightens internet restrictions

Mrs Xia, a 34-year-old English teacher from Guangdong province, says her husband's family wanted her to have a son to run the family business.

"I married into a wealthy family and my husband's mother was eager for me to have a boy. I considered having an abortion if the child was a girl - although I personally didn't mind either way.

"One of my best friends told me that she knew a doctor who runs a clinic that helps pregnant woman to check the gender of a baby. My friend gave me the address and I went with my husband. The test was not painful and lasted for just 15 minutes.

"As I am a teacher, I did not tell anyone about this experience except my family members, as the gender test is illegal in China."

Shanghai bucks the trend

According to the latest national census results, the gender gap shot back up in Shanghai - China's largest city with a population of 14 million people - for the first time in five years. Shanghai women gave birth to more than 112 boys to every 100 girls in 2014, up from 109.6 boys the previous year.

Professor Ruijun Wu from the School of Social Development, East China Normal University, says the rise can be largely attributed to an increased migrant population in the city in 2014.

"The newborn gender ratio among people from other cities is bigger than among Shanghai local population," she says.

While Shanghai's migrant population has certainly contributed to a higher newborn gender ratio than local residents in recent years, an official breakdown for last year's births has not yet been released.

I considered having an abortion if the child was a girl - although I personally didn't mind either way. Mrs Xia

China currently ranks in the world's top five worst performing countries for equal gender ratios at birth, and Chinese men now outnumber women by 33 million.

Politicians have fought to control the widening gap by limiting access to sex tests, and subsequent abortions of females. But there still remains almost no difficulty in finding out the gender of a foetus.

Mrs Liu, 30, works as a clerk in an insurance company in Shandong province and said it was easy to find out the sex of her unborn child.

"My uncle works at one of the largest and most renowned hospitals in the city. He persuaded a doctor to tell me the baby's gender. It cost the same as a normal antenatal test, 270 RMB [$43]."

Liu says she wouldn't have considered an abortion if the child was male - but was aware her husband's parents wanted her to have a boy.

For past decades, China's one-child policy has been blamed for skewing the gender balance sharply in favour of men.

Last year, the Chinese government relaxed family planning policies, allowing couples to have a second baby if one or both of the parents is an only child. Yet families with multiple children have continued to contribute to the gender imbalance.

"It's common for Shanghai local families to have a girl at first and then a boy," says Wu. "It's not because people prefer boys. It's because they think boys could burden more responsibilities. Girls can find it more difficult to find a job and get married if they are educated."

Traditional values

A survey of 1,000 people aged 25 to 36 in the Jing'an district of Shanghai last year suggested almost two-thirds did not have a specific preference about the future gender of their first child. In fact, 13.7 percent preferred to have a girl, and 8.7 percent a boy.

Yet when it comes to having second children, traditional values appear to prevail - regardless of personal preference.

While first-born children in China have roughly average sex ratios, the gender gap widens dramatically for second-born children, revealed a study of 2005 census data published in the British Medical Journal.

According to Wu's research, it is common for families to be concerned about the prospects for newborn girls in later life.

Xia says she was determined to have a boy.

"If the test had been wrong, I would have quit my job and had another baby. After all, they needed a son to take over the family business," says Xia.

No baby boom after one-child policy eased

In light of the census results, the Shanghai Health and Family Planning Commission plans to improve pregnancy reporting, tighten restrictions on sex-selective abortions, and toughen measures to prevent foetus gender tests.

In addition, Wu says the authorities should do more to change attitudes towards having daughters in the first place.

"I think the government should also deal with women's difficulties they are facing in job hunting and getting married.

"For instance, the government may encourage enterprises to employ women, or offer some services for women to meet their Mr Right."