Symbian
Symbian OS Library

FAQ-0920 What tips can you give me to avoid a Viewsrv 11 panic in my application?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Active Objects
Created: 09/05/2003 Modified: 09/08/2003
Number: FAQ-0920
Platform: Symbian OS v6.0, Symbian OS v6.1, Symbian OS v7.0, Symbian OS v7.0s

Question:
I am getting a Viewsrv 11 panic from my application - what tips can you give me to avoid this?

Answer:
Viewsrv 11 panics are a hazard when writing busy applications, for instance games. They occur when the Viewsrv active object in your, or any other, application does not respond to the view server in time. Typically 10-20 seconds is the maximum allowed response time - see FAQ-0900 for a more detailed explanation. Here are some guidelines for avoiding common causes of this problem:

1) Do not have long running synchronous operations. The Viewsrv system requires that the active scheduler in your application is able to run the Viewsrv active object. Long running synchronous operations will prevent this. For instance, games typically have a "main game loop", and one incorrect way to code this is "while (1) { GameStep(); }". However, this loop is synchronous, it does not return control to the scheduler, therefore it prevents the scheduler and Viewsrv's active object from running. Instead the steps should be triggered asynchronously, often achieved using a CIdle or CPeriodic active object as a source of events.

2) Ensure that your active objects don't swamp the scheduler. The active scheduler processes active objects strictly in priority order, and for those of the same priority, active objects added first have priority. Active objects that run often and use a lot of processing time should run at low priority. The Viewsrv active object runs at CActive::EPriorityStandard, so busy active objects should run at a lower priority. One note of warning: if you use EPriorityLow, ensure it is scoped as CActive::EPriorityLow, otherwise you may get thread priority EPriorityLow, which is actually a very high priority value for an active object!

3) Allow some CPU time for other applications. Foreground application threads often run at higher priority than background applications (the system does this automatically). Active objects in foreground applications, even those at a low active object priority, can prevent background applications from running. This can cause Viewsrv 11 panics to appear in other applications when your application is running. Therefore, applications should allow gaps for other applications to run in. If CPeriodic is used to drive a busy application, ensure that the time between each new step is slightly longer than a step takes to run. If CIdle is used, it will run as soon as possible, so force a small delay at the end of a step by calling User::After(0), which will give other applications a chance to run until the next processor tick (typically a 64th of a second).

4) Do not use User::WaitForRequest(); or similar blocking operations. They will allow other applications to run, but completely block the active scheduler in your application.

5) On some platforms, be aware that launching waiting dialogs (or performing other blocking actions) from ViewActivatedL(); or ViewDeactivatedL(); can also cause Viewsrv 11 panics. This is a feature of UIQ but not Series 60, for example.