Hi All, I have encountered a problem similar to the one asked in the https://groups.google.com/forum/?fromgroups=#!topic/android-developers/pGA32n8zvlI where video view is added dynamically to layout for the first time application runs we have got a screen flickering. I`m running 2.3.4 (and my source reference in from 2.3.4) but i have checked that the problem still exists even in jelly bean. I have digged into a source code and here is my findings : 1) When i create and activity with non-translucent theme for example with "@android:style/Theme.Black.NoTitleBar.Fullscreen", your are using 565 RGB layout in surface flinger .. (16 bits per pixel), 2) when you are adding SurfaceView to that layout view format is changed [in order to draw transparent region which is needed to enable video display beneath android frame buffer] (here is the source code): from SurfaceView: @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mParent.requestTransparentRegion(this); mSession = getWindowSession(); mLayout.token = getWindowToken(); mLayout.setTitle("SurfaceView"); mViewVisibility = getVisibility() == VISIBLE; getViewTreeObserver().addOnScrollChangedListener(mScrollChangedListener); } which in turn does the following: (from viewgroup.java) public void requestTransparentRegion(View child) { if (child != null) { child.mPrivateFlags |= View.REQUEST_TRANSPARENT_REGIONS; if (mParent != null) { mParent.requestTransparentRegion(this); } } } and this in turn causes the following code in ViewRoot.performTraversals() if (params != null && (host.mPrivateFlags & View.REQUEST_TRANSPARENT_REGIONS) != 0) { if (!PixelFormat.formatHasAlpha(params.format)) { params.format = PixelFormat.TRANSLUCENT; } } so you can see that now we have changed the format to translucent. Now lets check the code in WindowManagerService When we re-layout the following code runs WindowManager .copyFrom and it has the following lines: if (format != o.format) { format = o.format; changes |= FORMAT_CHANGED; } we obviously fall into this "case" because we just changed format. Now what happens next in WindowManagerService.relayoutWindow if ((attrChanges&WindowManager.LayoutParams.FORMAT_CHANGED) != 0) { // To change the format, we need to re-build the surface. win.destroySurfaceLocked(); displayed = true; } try { Surface surface = win.createSurfaceLocked(); if (surface != null) { outSurface.copyFrom(surface); win.mReportDestroySurface = false; win.mSurfacePendingDestroy = false; if (SHOW_TRANSACTIONS) Slog.i(TAG, " OUT SURFACE " + outSurface + ": copied"); } else { // For some reason there isn't a surface. Clear the // caller's object so they see the same state. outSurface.release(); } And this is where the flickering happens, what just had happened is that we have DELETED the surface that hosts our activity, and caused surfaceflinger to immediately redraw the screen, (without our activity on it), in which case "Wormhole" will be displayed as our activity took full-screen and left all other windows invisible. The only workaround i have found for this is to put dummy surface into activity XML (with visibility set to invisible) which will cause my activity to be 32bpp (bits per pixel) from the beginning and avoid flickering when adding video view. Can someone please advice on this issue ? Google ? Thanks, Regards Sasha. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en |