There are options in both iTunes and iOS devices that let their respective libraries show your purchase history. This explains why even an "empty" library or device may not be truly empty, and if isn't, why it only contains your store purchases.
I have no idea how common a problem the issue of the library being dumped is, either on iOS devices, or with the main iTunes library. I know that it happens. I know that it has happened to me. Apple know that there is a potential for things to go wrong with their devices and provide the restore mechanism to put things back as they were. It could be better, since as a rule iTunes only maintains a single rolling backup of the device settings and it is too easy for this to get updated with the current state of the device before a user spots a problem. This is why I recommend people disable the option on the device's summary page to Automatically sync when this device is connected, and enable the option under Edit > Preferences > Devices to Prevent iPods, iPhones, and iPads from syncing automatically. It also should be possible for either the device or iTunes to run some form of integrity checking and self repair process when there appears to be discrepancy between what is listed in the library and what has been stored in the device's media folders. As yet no such feature has been implemented.
On Mac/OS X users have a way to take snapshot copies of the iOS device backup sets. On Windows the only way is to periodically backup and then immediately restore the device. It is probably good practice to do this say once a month and then cull the older backups keeping at least two or three for each device.
Apple also know about the potential for the main library to get dumped since they have this support document No content shows up in iTunes after updating which gives similar advice to my user tip Empty/corrupt iTunes library after upgrade/crash. In the case of bigger problems with library whether caused by iTunes, third party software or hardware failure, a meaningful backup to the library is the only real defence. Murphy's law tells us things will go wrong at some point.
By and large people visit these forums because they have problems. Finding others with similar problems doesn't necessarily mean the issue is happening often enough to get significant attention from Apple. I've no idea how good Apple's support system is at taking the reports and passing them up the chain to people who can recognize what is going on and start work on a fix. As a part-time coder myself the hardest bugs to eliminate are the ones that I cannot reproduce. If they only happen on someone else's system it can be hard to get them to share enough information with me to make sense of what is going wrong. As well as the feedback forms, e.g. iTunes Feedback, or iPhone Feedback, you can also sign up for a free Apple Developer account and make use of Apple Bug Reporter. They don't generally talk back, but they do claim to read everything. Providing a useful bug report is hard work however, particularly if you're not able tightly define the the circumstances that generate the unwanted behaviour, and there is still no guarantee that anything will be changed as a result.
As I have said before, possibly in this thread, manually managing Apple devices takes more effort in the long run, particularly if a device needs to be restored or replaced. Working with selected playlists means you can manage the content that will go on the device whether it is connected at the time or not, and makes restoring a device a much smoother task.
When the media on the device won't refresh as expected during a sync the method that usually works is this:
- Export the contents of the camera roll. (You should do this routinely anyway.)
- Backup the device, unless you have a recent backup that you would prefer to restore.
- Restore as a new device. (The general restore process doesn't seem to clear things out before reloading, so there can be issues with missing artwork or incorrect capacity calculations.)
- Restore the chosen backup and give it time to complete.
In some cases it might pay to use the recovery mode method given in HT201263: If you can't update or restore your iPhone, iPad, or iPod touch at step 3 to ensure that a device has been completely reset before reloading your content. If the same thing happens again it could be that something that is captured and restored in the backup set is the trigger. Sadly restoring is an all or nothing affair, although I believe there are some third party tools that can selectively backup and restore data to individual apps.
If you've been through the process above and the device still dumps its content then perhaps there is some non-obvious factor at play. Back when I was using an iPod classic I found that certain smart playlists seemed to be too complicated for the device to manage and would cause it to crash, dumping the library on the device in the process. There is also an outside possibility that some third party apps that have access to the music database on the device could cause problems. Power saving settings on computers that put hardware to sleep after a period of inactivity might also be a factor in disrupted data transfers. It may also pay to check the source computer's hard drive for issues.
I do appreciate the frustration that comes with problems such as these. My impression is that this particular issue of devices dumping their libraries is relatively rare, compared say to the numbers of people who have trouble installing the current all 64-bit iTunes, which, one presumes, is but a tiny fraction when compared to those who update without any problems at all. That said I spend most of my time on ASC in the iTunes for Windows forums rather than Using iPhone, so I may be missing the wider picture. By saying it is rare I'm not trying to diminish the seriousness of it for you, but to put it in some context. Apple are going to concentrate on the issues that they can see occur widely before the ones that are more obscure. With regard to beta testing, no doubt some is done, but there are some problems that only come to light once end users start doing what they do in the real world.
tt2