Windows Phone Thoughts - Daily News, Views, Rants and Raves

Check out the hottest Windows Mobile devices at our Expansys store!


Digital Home Thoughts

Loading feed...

Laptop Thoughts

Loading feed...

Android Thoughts

Loading feed...




Go Back   Thoughts Media Forums > WINDOWS PHONE THOUGHTS > Windows Phone Talk

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2004, 06:58 AM
The PocketTV Team
Thinker
Join Date: Nov 2003
Posts: 484
Default WM2003 and SE: file handles become un-usable after power OFF/ON

It appears that MSFT managed to break something in WM2003 and WM2003-SE, and this can cause serious head-haches for developers, as there is no easy workaround.

The problem affects applications that read or write files located on removable storages (SD Cards, CF Cards).

In Pocket PC 2000 and Pocket PC 2002, when the device was turned OFF (i.e. "suspended"), then turned ON again later ("resumed"), all the files handles of files located on removable storages were re-mounted correctly by the filesystem drivers, i.e. basically the suspend/resume operation was totally transparent to all applications, including those that had open file handles to files located on removable storages.

The only caveat was described in this KB article: http://support.microsoft.com/default...b;en-us;811693 . Basically ReadFile could return an error when trying to read the file too soon after the power-resume. The workaround was simple: sleep a bit and retry. If it keeps failing after say 4 seconds, then abandon.

Now, in WM2003 and WM2003-SE, it appears that those file handles are not always remounted by the driver upon the power-resume, i.e. all file handles can become un-usable after a power suspend/resume for files located on removable storage (even though the storage card was left in the device while the device was suspended).

You may think: no big deal, the application can just re-open the file.

But think a bit more, and you will realize that by re-opening the file based on its pathname (e.g. "\SD Card\foo.xxx"), you have no guarantee that you are in fact opening the same file! While the device was suspended, the user may have replaced the Storage Card by another one that have a different file with the same name. Only the driver can verify that the Storage Card is the same, based on the filesystem signature, the Card ID etc. That's why the filesystem should be re-mounted by the driver, and all the file handles should remain valid, unless the storage card was changed.

And even if you re-open the file, it is not as simple: You also need to keep track of the current offset in the file (seek position), in order to get a new file handle that points to the same offset.

And your application must now expect each File System call (e.g. GetFileSize, SetFilePointer, ReadFile, WriteFile, GetFileAttributeByHandle, FlushFileBuffer, etc ) to fail since it has become a "normal" thing that will happen each time the user press the POWER OFF button (if your file is on a storage card).

I complained to MSFT that this was a serious bug that will cause problems to a number of apps and reported the issue to several MSFT Engineers at the Mobility Developer Conference. They did not take it seriously enough to file a bug report in the Knowledge Database.

When I insisted, two months later they assigned a contractor to look into the issue, and the feedback I got from the guy was: "it's by design, the product group said it's normal that file handles to files located on removable storages become un-usable after the device is suspended/resumed". This guy told me that "there was many improvements in WinCE 4.2, so some things have changed". That's definitely what I would call a "negative improvement".

I just cannot believe that this new bug is "by design", since it was working (almost) perfectly in Pocket PC 2000 and 2002. And if this was a change "by design", I would expect it to be documented, which is not the case.

Furthermore, http://msdn.microsoft.com/library/de...chitecture.asp clearly suggests that the storage Card drivers should remount correctly the filesystems on suspend/resume:

[...]This notification forces unmounts of the partition driver and any file systems. During this period, the mount points move into a suspended state and requested I/O access to the mount points fail with ERROR_DEVICE_NOT_AVAILABLE. The primary use for this is during suspend/resume cycles where a block driver might unload and reload on resume. When the Storage Manager receives a load notification, it examines the block device to see if it is identical to the previously unmounted device. If it is identical, the block device remounts under the previous mount points.
 
Reply With Quote
  #2  
Old 05-04-2004, 07:19 AM
ChristopherTD
Thinker
Join Date: Mar 2004
Posts: 485

This is bizarre because the latest ROM (1.10.10) for my iPaq 5550 fixed this problem!

Before the ROM update any application that was suspended with files open on a Storage Card would behave unpredictably. These apps included Microsoft Reader and Laridian Pocket Bible.

After the ROM update they behave as expected, allowing you to resume reading without incident.

I hope that WM2003SE (final release) doesn't break this because it would be a showstopper for me. Fortunately I am in no rush to upgrade!
 
Reply With Quote
  #3  
Old 05-04-2004, 08:10 AM
The PocketTV Team
Thinker
Join Date: Nov 2003
Posts: 484

> Before the ROM update any application that was suspended with files open on a Storage Card would behave unpredictably.

That's what we observe with all the WM2003-SE devices that we have tested.

We also observe this on the Toshiba e800 (WM2003).
 
Reply With Quote
  #4  
Old 05-04-2004, 08:24 AM
socrates63
Intellectual
Join Date: Mar 2004
Posts: 126

So this seems to be the answer to the problems I experienced a couple of months ago. Things improved significantly when I installed the critical apps (SIP, Pocket Informant, Wisbar, etc.) to main memory upon advice from a PPCT member. Prior to that, my 2215 would freeze when I turned it back on after it had turned itself off. I never had problems of this sort on my PPC 2002 device. I almost returned the 2215.
 
Reply With Quote
  #5  
Old 05-04-2004, 10:06 AM
The PocketTV Team
Thinker
Join Date: Nov 2003
Posts: 484

Quote:
Originally Posted by socrates63
So this seems to be the answer to the problems I experienced a couple of months ago. Things improved significantly when I installed the critical apps (SIP, Pocket Informant, Wisbar, etc.) to main memory upon advice from a PPCT member. Prior to that, my 2215 would freeze when I turned it back on after it had turned itself off. I never had problems of this sort on my PPC 2002 device. I almost returned the 2215.
Yes, I could be related if those applications open a data file located in their installation folder.
 
Reply With Quote
  #6  
Old 05-04-2004, 10:36 AM
Fishie
Pontificator
Join Date: Mar 2004
Posts: 1,479

Quote:
Originally Posted by The PocketTV Team
> Before the ROM update any application that was suspended with files open on a Storage Card would behave unpredictably.

That's what we observe with all the WM2003-SE devices that we have tested.

We also observe this on the Toshiba e800 (WM2003).
So thats what it was.

I noticed that after removing my CF card and taking pictures with my digicam upon reinsertion it hanged and I could no longer search the file system, sometimes even a reset didnt change that.

Its a major bug and made half my machine unfunctional.

Resco file explorer came to my rescue and after using that to open some files on the card it decided to work again last time that it happened.
 
Reply With Quote
  #7  
Old 05-04-2004, 10:48 AM
The PocketTV Team
Thinker
Join Date: Nov 2003
Posts: 484

Fishie,

When you take out the Storage Card, change its contents (e.g. take photos), and put it back, the Pocket PC should detect that the filesystem has changed, so it should remount a new one (and invalidate any previously opened handles). Normally you should be able to search the newly mounted filesystem, but there may be another bug preventing it.

Even though you describe a problem that may have to do with mounted filesystems, it seems unrelated to the problem we are talking about here.

The problem we are discussing here involves only suspending/resuming the device, without taking out any storage card.
 
Reply With Quote
  #8  
Old 05-04-2004, 03:40 PM
Fishie
Pontificator
Join Date: Mar 2004
Posts: 1,479

Ah, ok.

Thanks for the clarification.
 
Reply With Quote
  #9  
Old 05-04-2004, 11:14 PM
KenClunk
Intellectual
Join Date: Nov 2004
Posts: 118

This kind of thing is going to make me... wait to upgrade. I think I am going to set a limit of 1 month after release before I upgrade. I want to let everyone else test it out first. Of corse I have no will power so I will probably do it anyways. Oh well.
 
Reply With Quote
  #10  
Old 05-05-2004, 08:13 AM
The PocketTV Team
Thinker
Join Date: Nov 2003
Posts: 484

Quote:
Originally Posted by KenClunk
This kind of thing is going to make me... wait to upgrade. I think I am going to set a limit of 1 month after release before I upgrade. I want to let everyone else test it out first. Of corse I have no will power so I will probably do it anyways. Oh well.
This problem is already present in some WM2003 and WM2003-SE devices (e.g. on the e800).

I think the real source of the issue, here, is that the test suite provided by MSFT to the Manufacturers (to test if all the features of the OS are implemented correctly) does not contain any tests to check that things work as they should upon power suspend/resume.

So the OEM just presses the Power button and check that the device turns back ON. But that's not enough! Many invisible things can happen. Like the one this thread is about (i.e. all the handles of files located on storage cards are not re-mounted correctly and become permanently invalid).

In the process of testing this, we also found that very often, devices have problems with their audio driver upon power suspend/resume, i.e. audio starts making funning craking sounds after the device was powered OFF while playing audio, or audio just stops working all together (require a soft reset). That's the case with the e800, too.
 
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:49 AM.