Phantom images on SurfaceView if app comes to forground again before onPause completesphantom images after going from split screen to full screenGeneral Android semi transparent bugAndroid NDK - how to create multiple bitmaps given only size (width and height)android ANativeWindow_lock api doesn't work for GLSurfaceViewBlending issue porting from OpenGLES 1.0 to 2.0 (iOS)OpenGL blending renders black on black as gray?Native window queueBuffer function not rendering output from Stagefright decoderVulkan and transparent windowsSurfaceview/TextureView for subtitles alpha does not workOpengl ES 1.0 2D only last drawn texture is displayedphantom images after going from split screen to full screen
Did we get closer to another plane than we were supposed to, or was the pilot just protecting our delicate sensibilities?
Why is "breaking the mould" positively connoted?
ZSPL language, anyone heard of it?
Why do people keep telling me that I am a bad photographer?
How to adjust tikz picture so it fits to current size of a table cell?
Wrong answer from DSolve when solving a differential equation
How I can I roll a number of non-digital dice to get a random number between 1 and 150?
Emotional immaturity of comic-book version of superhero Shazam
Why did the Apollo 13 crew extend the LM landing gear?
What exactly are the `size issues' preventing formation of presheaves being a left adjoint to some forgetful functor?
How can I get people to remember my character's gender?
Should homeowners insurance cover the cost of the home?
Identifying characters
How to safely wipe a USB flash drive
Building a list of products from the elements in another list
Frequency of specific viral sequence in .BAM or .fastq
Out of scope work duties and resignation
Floor of Riemann zeta function
exec command in bash loop
SafeCracker #3 - We've Been Blocked
Why does sound not move through a wall?
How can internet speed be 10 times slower without a router than when using a router?
What does this wavy downward arrow preceding a piano chord mean?
How to use dependency injection and avoid temporal coupling?
Phantom images on SurfaceView if app comes to forground again before onPause completes
phantom images after going from split screen to full screenGeneral Android semi transparent bugAndroid NDK - how to create multiple bitmaps given only size (width and height)android ANativeWindow_lock api doesn't work for GLSurfaceViewBlending issue porting from OpenGLES 1.0 to 2.0 (iOS)OpenGL blending renders black on black as gray?Native window queueBuffer function not rendering output from Stagefright decoderVulkan and transparent windowsSurfaceview/TextureView for subtitles alpha does not workOpengl ES 1.0 2D only last drawn texture is displayedphantom images after going from split screen to full screen
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am writing a game for Android using the Java for the user interface and C++ with the NDK for the render thread. It uses Vulkan if available and otherwise uses OpenGL ES. This bug occurs in OpenGL ES and Vulkan.
If I pause the app and quickly resume it before either onPause, onStop, or SurfaceHolder.Callback.surfaceDestroyed completes, then there will be an afterimage of what was shown on the surface immediately before the render thread stops. The afterimage behaves like a background to any new thing I draw. When performing the render pass I set the clear color to: black with 0.0 for alpha. I do this so that the app's background will be the background for the game. If I set the alpha value to 1.0, then the symptoms of this bug will not present themselves.
This problem can be viewed as a generalization of the problem described in:
phantom images after going from split screen to full screen
But the solution to that problem (i.e. avoiding shutting down the app) will not work for this more general case.
I am stopping the render thread during onPause or SurfaceHolder.Callback.surfaceDestroyed, which ever one happens first. These functions will not return until the render thread is joined (if there is one).
If I clear the screen by using an empty render pass with the clear color being black and 0.0 for alpha (in Vulkan) or by calling glClear (in OpenGL ES) before the render thread shuts down, then the bug does not manifest. But this stinks of something being done wrong with the surface (or perhaps some sort of race condition). I am worried that this solution just hides the bug instead of fixing it by freeing the resources associated with the afterimage. Is there something else I need to do to ensure that the surface is reset correctly?
Beginning the render pass (vulkan):
std::array<VkClearValue, 2> clearValues = ;
clearValues[0].color = 0.0f, 0.0f, 0.0f, 0.0f;
clearValues[1].depthStencil = 1.0, 0;
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
During initialization in OpenGL ES:
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
clearing the screen in the drawing loop (OpenGL):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
In the render thread, this is the set up and tear down of the ANativeWindow. I checked in the debugger that the shared pointer deleter was actually called:
ANativeWindow *window = ANativeWindow_fromSurface(env, jsurface);
if (window == nullptr)
notify->sendError("Unable to acquire window from surface.");
return;
auto deleter = [](WindowType *windowRaw)
/* release the java window object */
if (windowRaw != nullptr)
ANativeWindow_release(windowRaw);
;
std::shared_ptr<WindowType> surface(window, deleter);
in onPause and SurfaceHolder.Callback.surfaceDestroyed:
if (drawer == null)
return;
try
Draw.tellDrawerStop();
drawer.join();
catch (InterruptedException e)
drawer = null;
The following is done in onCreate to make the SurfaceView see through:
SurfaceView drawSurfaceView = findViewById(R.id.drawingSurface);
drawSurfaceView.setZOrderOnTop(true);
SurfaceHolder drawSurfaceHolder = drawSurfaceView.getHolder();
drawSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
drawSurfaceHolder.addCallback(new MySurfaceCallback(this));
android opengl-es android-ndk vulkan
add a comment |
I am writing a game for Android using the Java for the user interface and C++ with the NDK for the render thread. It uses Vulkan if available and otherwise uses OpenGL ES. This bug occurs in OpenGL ES and Vulkan.
If I pause the app and quickly resume it before either onPause, onStop, or SurfaceHolder.Callback.surfaceDestroyed completes, then there will be an afterimage of what was shown on the surface immediately before the render thread stops. The afterimage behaves like a background to any new thing I draw. When performing the render pass I set the clear color to: black with 0.0 for alpha. I do this so that the app's background will be the background for the game. If I set the alpha value to 1.0, then the symptoms of this bug will not present themselves.
This problem can be viewed as a generalization of the problem described in:
phantom images after going from split screen to full screen
But the solution to that problem (i.e. avoiding shutting down the app) will not work for this more general case.
I am stopping the render thread during onPause or SurfaceHolder.Callback.surfaceDestroyed, which ever one happens first. These functions will not return until the render thread is joined (if there is one).
If I clear the screen by using an empty render pass with the clear color being black and 0.0 for alpha (in Vulkan) or by calling glClear (in OpenGL ES) before the render thread shuts down, then the bug does not manifest. But this stinks of something being done wrong with the surface (or perhaps some sort of race condition). I am worried that this solution just hides the bug instead of fixing it by freeing the resources associated with the afterimage. Is there something else I need to do to ensure that the surface is reset correctly?
Beginning the render pass (vulkan):
std::array<VkClearValue, 2> clearValues = ;
clearValues[0].color = 0.0f, 0.0f, 0.0f, 0.0f;
clearValues[1].depthStencil = 1.0, 0;
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
During initialization in OpenGL ES:
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
clearing the screen in the drawing loop (OpenGL):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
In the render thread, this is the set up and tear down of the ANativeWindow. I checked in the debugger that the shared pointer deleter was actually called:
ANativeWindow *window = ANativeWindow_fromSurface(env, jsurface);
if (window == nullptr)
notify->sendError("Unable to acquire window from surface.");
return;
auto deleter = [](WindowType *windowRaw)
/* release the java window object */
if (windowRaw != nullptr)
ANativeWindow_release(windowRaw);
;
std::shared_ptr<WindowType> surface(window, deleter);
in onPause and SurfaceHolder.Callback.surfaceDestroyed:
if (drawer == null)
return;
try
Draw.tellDrawerStop();
drawer.join();
catch (InterruptedException e)
drawer = null;
The following is done in onCreate to make the SurfaceView see through:
SurfaceView drawSurfaceView = findViewById(R.id.drawingSurface);
drawSurfaceView.setZOrderOnTop(true);
SurfaceHolder drawSurfaceHolder = drawSurfaceView.getHolder();
drawSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
drawSurfaceHolder.addCallback(new MySurfaceCallback(this));
android opengl-es android-ndk vulkan
add a comment |
I am writing a game for Android using the Java for the user interface and C++ with the NDK for the render thread. It uses Vulkan if available and otherwise uses OpenGL ES. This bug occurs in OpenGL ES and Vulkan.
If I pause the app and quickly resume it before either onPause, onStop, or SurfaceHolder.Callback.surfaceDestroyed completes, then there will be an afterimage of what was shown on the surface immediately before the render thread stops. The afterimage behaves like a background to any new thing I draw. When performing the render pass I set the clear color to: black with 0.0 for alpha. I do this so that the app's background will be the background for the game. If I set the alpha value to 1.0, then the symptoms of this bug will not present themselves.
This problem can be viewed as a generalization of the problem described in:
phantom images after going from split screen to full screen
But the solution to that problem (i.e. avoiding shutting down the app) will not work for this more general case.
I am stopping the render thread during onPause or SurfaceHolder.Callback.surfaceDestroyed, which ever one happens first. These functions will not return until the render thread is joined (if there is one).
If I clear the screen by using an empty render pass with the clear color being black and 0.0 for alpha (in Vulkan) or by calling glClear (in OpenGL ES) before the render thread shuts down, then the bug does not manifest. But this stinks of something being done wrong with the surface (or perhaps some sort of race condition). I am worried that this solution just hides the bug instead of fixing it by freeing the resources associated with the afterimage. Is there something else I need to do to ensure that the surface is reset correctly?
Beginning the render pass (vulkan):
std::array<VkClearValue, 2> clearValues = ;
clearValues[0].color = 0.0f, 0.0f, 0.0f, 0.0f;
clearValues[1].depthStencil = 1.0, 0;
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
During initialization in OpenGL ES:
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
clearing the screen in the drawing loop (OpenGL):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
In the render thread, this is the set up and tear down of the ANativeWindow. I checked in the debugger that the shared pointer deleter was actually called:
ANativeWindow *window = ANativeWindow_fromSurface(env, jsurface);
if (window == nullptr)
notify->sendError("Unable to acquire window from surface.");
return;
auto deleter = [](WindowType *windowRaw)
/* release the java window object */
if (windowRaw != nullptr)
ANativeWindow_release(windowRaw);
;
std::shared_ptr<WindowType> surface(window, deleter);
in onPause and SurfaceHolder.Callback.surfaceDestroyed:
if (drawer == null)
return;
try
Draw.tellDrawerStop();
drawer.join();
catch (InterruptedException e)
drawer = null;
The following is done in onCreate to make the SurfaceView see through:
SurfaceView drawSurfaceView = findViewById(R.id.drawingSurface);
drawSurfaceView.setZOrderOnTop(true);
SurfaceHolder drawSurfaceHolder = drawSurfaceView.getHolder();
drawSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
drawSurfaceHolder.addCallback(new MySurfaceCallback(this));
android opengl-es android-ndk vulkan
I am writing a game for Android using the Java for the user interface and C++ with the NDK for the render thread. It uses Vulkan if available and otherwise uses OpenGL ES. This bug occurs in OpenGL ES and Vulkan.
If I pause the app and quickly resume it before either onPause, onStop, or SurfaceHolder.Callback.surfaceDestroyed completes, then there will be an afterimage of what was shown on the surface immediately before the render thread stops. The afterimage behaves like a background to any new thing I draw. When performing the render pass I set the clear color to: black with 0.0 for alpha. I do this so that the app's background will be the background for the game. If I set the alpha value to 1.0, then the symptoms of this bug will not present themselves.
This problem can be viewed as a generalization of the problem described in:
phantom images after going from split screen to full screen
But the solution to that problem (i.e. avoiding shutting down the app) will not work for this more general case.
I am stopping the render thread during onPause or SurfaceHolder.Callback.surfaceDestroyed, which ever one happens first. These functions will not return until the render thread is joined (if there is one).
If I clear the screen by using an empty render pass with the clear color being black and 0.0 for alpha (in Vulkan) or by calling glClear (in OpenGL ES) before the render thread shuts down, then the bug does not manifest. But this stinks of something being done wrong with the surface (or perhaps some sort of race condition). I am worried that this solution just hides the bug instead of fixing it by freeing the resources associated with the afterimage. Is there something else I need to do to ensure that the surface is reset correctly?
Beginning the render pass (vulkan):
std::array<VkClearValue, 2> clearValues = ;
clearValues[0].color = 0.0f, 0.0f, 0.0f, 0.0f;
clearValues[1].depthStencil = 1.0, 0;
renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
renderPassInfo.pClearValues = clearValues.data();
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
During initialization in OpenGL ES:
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
clearing the screen in the drawing loop (OpenGL):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
In the render thread, this is the set up and tear down of the ANativeWindow. I checked in the debugger that the shared pointer deleter was actually called:
ANativeWindow *window = ANativeWindow_fromSurface(env, jsurface);
if (window == nullptr)
notify->sendError("Unable to acquire window from surface.");
return;
auto deleter = [](WindowType *windowRaw)
/* release the java window object */
if (windowRaw != nullptr)
ANativeWindow_release(windowRaw);
;
std::shared_ptr<WindowType> surface(window, deleter);
in onPause and SurfaceHolder.Callback.surfaceDestroyed:
if (drawer == null)
return;
try
Draw.tellDrawerStop();
drawer.join();
catch (InterruptedException e)
drawer = null;
The following is done in onCreate to make the SurfaceView see through:
SurfaceView drawSurfaceView = findViewById(R.id.drawingSurface);
drawSurfaceView.setZOrderOnTop(true);
SurfaceHolder drawSurfaceHolder = drawSurfaceView.getHolder();
drawSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
drawSurfaceHolder.addCallback(new MySurfaceCallback(this));
android opengl-es android-ndk vulkan
android opengl-es android-ndk vulkan
edited Mar 24 at 14:47
Cerulean Quasar
asked Mar 22 at 23:00
Cerulean QuasarCerulean Quasar
4016
4016
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308837%2fphantom-images-on-surfaceview-if-app-comes-to-forground-again-before-onpause-com%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308837%2fphantom-images-on-surfaceview-if-app-comes-to-forground-again-before-onpause-com%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown