Bug 1750569 - Add test to ensure screen pixels requests succeed if the GPU process crashes. r=agi

Differential Revision: https://phabricator.services.mozilla.com/D136152
This commit is contained in:
Jamie Nicol 2022-01-19 16:14:30 +00:00
parent 5ecbc5e1b3
commit 3d79bd207c
5 changed files with 48 additions and 0 deletions

View File

@ -62,6 +62,9 @@ const APIS = {
UsingGpuProcess() {
return browser.test.usingGpuProcess();
},
KillGpuProcess() {
return browser.test.killGpuProcess();
},
CrashGpuProcess() {
return browser.test.crashGpuProcess();
},

View File

@ -167,6 +167,13 @@ this.test = class extends ExtensionAPI {
return gfxInfo.usingGPUProcess;
},
async killGpuProcess() {
const gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(
Ci.nsIGfxInfo
);
return gfxInfo.killGPUProcessForTests();
},
async crashGpuProcess() {
const gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(
Ci.nsIGfxInfo

View File

@ -210,6 +210,14 @@
"parameters": []
},
{
"name": "killGpuProcess",
"type": "function",
"async": true,
"description": "Kills the GPU process cleanly without generating a crash report.",
"parameters": []
},
{
"name": "crashGpuProcess",
"type": "function",

View File

@ -29,6 +29,7 @@ import android.graphics.BitmapFactory
import android.graphics.Bitmap
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assume.assumeThat
import org.junit.Assume.assumeTrue
import java.lang.IllegalStateException
private const val SCREEN_HEIGHT = 800
@ -228,6 +229,30 @@ class ScreenshotTest : BaseSessionTest() {
}
}
@WithDisplay(height = SCREEN_HEIGHT, width = SCREEN_WIDTH)
@Test
fun capturePixelsBeforeGpuProcessCrash() {
// We need the GPU process for this test
assumeTrue(sessionRule.usingGpuProcess())
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
mainSession.loadTestPath(COLORS_HTML_PATH)
sessionRule.waitUntilCalled(object : ContentDelegate {
@AssertCalled(count = 1)
override fun onFirstContentfulPaint(session: GeckoSession) {
}
})
sessionRule.display?.let {
// Request screen pixels then immediately kill the GPU process
val result = it.capturePixels()
sessionRule.killGpuProcess()
assertScreenshotResult(result, screenshotFile)
}
}
@WithDisplay(height = SCREEN_HEIGHT, width = SCREEN_WIDTH)
@Test
fun screenshotToBitmap() {

View File

@ -2422,6 +2422,11 @@ public class GeckoSessionTestRule implements TestRule {
return (Boolean) webExtensionApiCall("UsingGpuProcess", null);
}
/** Kills the GPU process cleanly with generating a crash report. */
public void killGpuProcess() {
webExtensionApiCall("KillGpuProcess", null);
}
/** Causes the GPU process to crash. */
public void crashGpuProcess() {
webExtensionApiCall("CrashGpuProcess", null);