Index: trunk/src/VBox/GuestHost/OpenGL/include/chromium.h
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/include/chromium.h	(revision 48078)
+++ trunk/src/VBox/GuestHost/OpenGL/include/chromium.h	(revision 48079)
@@ -724,4 +724,6 @@
 /* guest requests host whether e debug break is needed*/
 #define GL_DBG_CHECK_BREAK_CR         0x8B2C
+/* Tells renderspu the default context id being used by the crserver */
+#define GL_HH_SET_DEFAULT_SHARED_CTX  0x8B2D
 
 /**********************************************************************/
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c	(revision 48078)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c	(revision 48079)
@@ -63,4 +63,6 @@
         cr_server.firstCallCreateContext = GL_FALSE;
         fFirst = GL_TRUE;
+
+        cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
     }
     else {
@@ -71,5 +73,5 @@
             /* the new context needs new visual attributes */
             cr_server.MainContextInfo.CreateInfo.visualBits |= visualBits;
-            crDebug("crServerDispatchCreateContext requires new visual (0x%x).",
+            crWarning("crServerDispatchCreateContext requires new visual (0x%x).",
                     cr_server.MainContextInfo.CreateInfo.visualBits);
 
@@ -95,4 +97,8 @@
                 return -1;
             }
+
+            /* we do not need to clean up the old default context explicitly, since the above cr_server.head_spu->dispatch_table.DestroyContext call
+             * will do that for us */
+            cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
         }
     }
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c	(revision 48078)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c	(revision 48079)
@@ -274,4 +274,7 @@
     case GL_HOST_WND_CREATED_HIDDEN_CR:
         cr_server.bWindowsInitiallyHidden = value ? 1 : 0;
+        break;
+    case GL_HH_SET_DEFAULT_SHARED_CTX:
+        crWarning("Recieved GL_HH_SET_DEFAULT_SHARED_CTX from guest, ignoring");
         break;
     default:
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 48078)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 48079)
@@ -16,4 +16,6 @@
 #include <iprt/asm.h>
 
+uint32_t renderspuContextRelease(ContextInfo *context);
+uint32_t renderspuContextRetain(ContextInfo *context);
 
 static void
@@ -183,5 +185,6 @@
 
     if (sharedContext)
-        ASMAtomicIncU32(&sharedContext->cRefs);
+        renderspuContextRetain(sharedContext);
+
     context->cRefs = 1;
 
@@ -215,5 +218,4 @@
 }
 
-static uint32_t renderspuContextRelease( ContextInfo *context );
 static void renderspuDestroyContextTerminate( ContextInfo *context )
 {
@@ -231,5 +233,11 @@
 }
 
-static uint32_t renderspuContextRelease( ContextInfo *context )
+uint32_t renderspuContextRetain( ContextInfo *context )
+{
+    Assert(context->cRefs);
+    return ASMAtomicIncU32(&context->cRefs);
+}
+
+uint32_t renderspuContextRelease( ContextInfo *context )
 {
     uint32_t cRefs = ASMAtomicDecU32(&context->cRefs);
@@ -251,4 +259,20 @@
 }
 
+ContextInfo * renderspuDefaultSharedContextAcquire()
+{
+    ContextInfo * pCtx = render_spu.defaultSharedContext;
+    if (!pCtx)
+        return NULL;
+
+    renderspuContextRetain(pCtx);
+    return pCtx;
+}
+
+void renderspuDefaultSharedContextRelease(ContextInfo * pCtx)
+{
+    renderspuContextRelease(pCtx);
+}
+
+
 static void RENDER_APIENTRY
 renderspuDestroyContext( GLint ctx )
@@ -265,11 +289,15 @@
 
     context = (ContextInfo *) crHashtableSearch(render_spu.contextTable, ctx);
-    CRASSERT(context);
-    {
-        if (!context)
-        {
-            crWarning("request to delete inexistent context");
-            return;
-        }
+
+    if (!context)
+    {
+        crWarning("request to delete inexistent context");
+        return;
+    }
+
+    if (render_spu.defaultSharedContext == context)
+    {
+        renderspuContextRelease(render_spu.defaultSharedContext);
+        render_spu.defaultSharedContext = NULL;
     }
 
@@ -748,5 +776,6 @@
         {
             int rc;
-            CR_BLITTER_CONTEXT ctx;
+            ContextInfo * pDefaultCtxInfo;
+
             pBlitter = (PCR_BLITTER)crCalloc(sizeof (*pBlitter));
             if (!pBlitter)
@@ -756,9 +785,17 @@
             }
 
-            /* @todo: this is the assumption that crserverlib uses context 1 as a default one
-             * need to do it in a more proper way */
-            ctx.Base.id = 1;
-            ctx.Base.visualBits = window->visual->visAttribs;
-            rc = CrBltInit(pBlitter, &ctx, true, true, render_spu.blitterDispatch);
+            pDefaultCtxInfo = renderspuDefaultSharedContextAcquire();
+            if (!pDefaultCtxInfo)
+            {
+                crWarning("no default ctx info!");
+                crFree(pBlitter);
+                return NULL;
+            }
+
+            rc = CrBltInit(pBlitter, &pDefaultCtxInfo->BltInfo, true, true, render_spu.blitterDispatch);
+
+            /* we can release it either way, since it will be retained when used as a shared context */
+            renderspuDefaultSharedContextRelease(pDefaultCtxInfo);
+
             if (!RT_SUCCESS(rc))
             {
@@ -1231,4 +1268,21 @@
     switch (target)
     {
+        case GL_HH_SET_DEFAULT_SHARED_CTX:
+            if (render_spu.defaultSharedContext)
+            {
+                renderspuContextRelease(render_spu.defaultSharedContext);
+                render_spu.defaultSharedContext = NULL;
+            }
+
+            if (value)
+            {
+                render_spu.defaultSharedContext = (ContextInfo *) crHashtableSearch(render_spu.contextTable, value);
+                if (render_spu.defaultSharedContext)
+                    renderspuContextRetain(render_spu.defaultSharedContext);
+                else
+                    crWarning("invalid default shared context id %d", value);
+            }
+
+            break;
         default:
 //            crWarning("Unhandled target in renderspuChromiumParameteriCR()");
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 48078)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 48079)
@@ -258,4 +258,6 @@
     CRHashTable *windowTable;
     CRHashTable *contextTable;
+
+    ContextInfo *defaultSharedContext;
 
 #ifndef CHROMIUM_THREADSAFE
@@ -418,4 +420,9 @@
 extern uint32_t renderspuContextMarkDeletedAndRelease( ContextInfo *context );
 
+ContextInfo * renderspuDefaultSharedContextAcquire();
+void renderspuDefaultSharedContextRelease(ContextInfo * pCtx);
+uint32_t renderspuContextRelease(ContextInfo *context);
+uint32_t renderspuContextRetain(ContextInfo *context);
+
 #ifdef __cplusplus
 extern "C" {
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 48078)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 48079)
@@ -1781,4 +1781,7 @@
 {
     NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
+    
+    /* view should not necesserily have a context set 
+     * @todo: check and set default shared one */
 
     [(OverlayView*)pView presentComposition:pChangedEntry];
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c	(revision 48078)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c	(revision 48079)
@@ -446,4 +446,10 @@
     }
 
+    if (render_spu.defaultSharedContext)
+    {
+        renderspuContextRelease(render_spu.defaultSharedContext);
+        render_spu.defaultSharedContext = NULL;
+    }
+
     crFreeHashtable(render_spu.contextTable, DeleteContextCallback);
     render_spu.contextTable = NULL;
