Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UI to display different instructions for different error codes #1137

Merged
merged 4 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 58 additions & 24 deletions gapic/src/main/com/google/gapid/models/Devices.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,45 +454,79 @@ public final Service.TraceTypeCapabilities getTypeCapabilities(Service.TraceType
}

public static class DeviceValidationResult {
public static final DeviceValidationResult PASSED = new DeviceValidationResult(null, null, "", true, false);
public static final DeviceValidationResult FAILED = new DeviceValidationResult(null, null, "", false, false);
public static final DeviceValidationResult SKIPPED = new DeviceValidationResult(null, null, "", true, true);
public static final DeviceValidationResult PASSED = new DeviceValidationResult(
Service.DeviceValidationResult.ErrorCode.OK, "", "", false);
public static final DeviceValidationResult FAILED = new DeviceValidationResult(
Service.DeviceValidationResult.ErrorCode.FAILED_PRECONDITION, "", "", false);
public static final DeviceValidationResult SKIPPED = new DeviceValidationResult(
Service.DeviceValidationResult.ErrorCode.OK, "", "", true);

// Corresponds to the error code from service.proto, but also includes Internal
public static enum ErrorCode {
Invalid,
Ok,
FailedPrecondition,
FailedTraceValidation,
Internal,
}

public final RpcException internalErr;
public final ErrorCode errorCode;
public final String validationFailureMsg;
public final String tracePath;
public final boolean passed;
public final boolean skipped;

public DeviceValidationResult(RpcException internalErr, String validationFailureMsg, String tracePath, boolean passed, boolean skipped) {
this.internalErr = internalErr;
public DeviceValidationResult(Service.DeviceValidationResult r) {
this(r.getErrorCode(),
r.getValidationFailureMsg(),
r.getTracePath(),
false);
}

public DeviceValidationResult(RpcException e) {
this(ErrorCode.Internal, e.toString(), "", false);
}

private DeviceValidationResult(Service.DeviceValidationResult.ErrorCode errorCode, String validationFailureMsg, String tracePath, boolean skipped) {
this.errorCode = ConvertErrorCode(errorCode);
this.validationFailureMsg = validationFailureMsg;
this.tracePath = tracePath;
this.passed = passed;
this.skipped = skipped;
}

public DeviceValidationResult(Service.DeviceValidationResult r) {
this(null,
r.getValidationFailureMsg(),
r.getTracePath(),
r.getValidationFailureMsg().length() == 0,
false);
private DeviceValidationResult(ErrorCode errorCode, String validationFailureMsg, String tracePath, boolean skipped) {
this.errorCode = errorCode;
this.validationFailureMsg = validationFailureMsg;
this.tracePath = tracePath;
this.skipped = skipped;
}

public DeviceValidationResult(RpcException e) {
this(e, e.toString(), "", false, false);
private ErrorCode ConvertErrorCode(Service.DeviceValidationResult.ErrorCode errorCode) {
switch (errorCode) {
case OK:
return ErrorCode.Ok;
case FAILED_PRECONDITION:
return ErrorCode.FailedPrecondition;
case FAILED_TRACE_VALIDATION:
return ErrorCode.FailedTraceValidation;
default:
return ErrorCode.Invalid;
}
}

public boolean passed() {
return errorCode == ErrorCode.Ok;
}


public boolean passedOrSkipped() {
return passed() || skipped;
}

@Override
public String toString() {
if (this.skipped) {
return "skipped";
} else if (this.passed) {
return "passed";
} else {
return "failed";
}
return errorCode.toString() +
(errorCode != ErrorCode.Ok ? " Error" : "") +
": " + validationFailureMsg;
}
}

Expand Down Expand Up @@ -528,7 +562,7 @@ public DeviceValidationResult getFromCache(Device.Instance device) {
}

public DeviceValidationResult add(Device.Instance device, DeviceValidationResult result) {
if (result.passed) {
if (result.passed()) {
Key key = new Key(device);
cache.put(key, stored.addValidationEntriesBuilder()
.setDevice(key.device)
Expand Down
13 changes: 12 additions & 1 deletion gapic/src/main/com/google/gapid/util/Logging.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public interface Listener {

private static final Listener NULL_LISTENER = (m) -> { /* do nothing */ };

private static final String SERVER_LOG_FILE = "gapis.log";
private static final String CLIENT_LOG_FILE = "gapic.log";

private static Listener listener = NULL_LISTENER;
private static long timeOfLastThrottledMessage = 0;

Expand Down Expand Up @@ -144,7 +147,7 @@ private static void initFileHandler(Logger rootLogger) {
File dir = new File(logDir.get());
dir.mkdirs();

File file = new File(dir, "gapic.log");
File file = new File(dir, CLIENT_LOG_FILE);
for (int i = 0; i < 10; i++) {
if (!file.exists() || file.canWrite()) {
try {
Expand Down Expand Up @@ -172,6 +175,14 @@ public static File getLogDir() {
return logDir.get().isEmpty() ? null : new File(logDir.get());
}

public static File getServerLogFile() {
return new File(getLogDir(), SERVER_LOG_FILE);
}

public static File getClientLogFile() {
return new File(getLogDir(), CLIENT_LOG_FILE);
}

public static String getGapisLogLevel() {
return (gapisLogLevel.isSpecified() ? gapisLogLevel.get() : logLevel.get()).gapisLevel;
}
Expand Down
2 changes: 1 addition & 1 deletion gapic/src/main/com/google/gapid/util/URLs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class URLs {
public static final String FILE_BUG_URL =
"https://github.com/google/agi/issues/new?template=standard-bug-report-for-gapid.md";
public static final String DEVICE_COMPATIBILITY_URL = "https://gpuinspector.dev/validation";
public static final String DEVICE_COMPATIBILITY_URL = "https://developer.android.com/agi/supported-devices";
public static final String EXPECTED_ANGLE_PREFIX = "https://agi-angle.storage.googleapis.com/";
public static final String ANGLE_DOWNLOAD = EXPECTED_ANGLE_PREFIX + "index.html";

Expand Down
2 changes: 1 addition & 1 deletion gapic/src/main/com/google/gapid/views/DeviceDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected void selectReplayDevice() {
&& models.devices.getReplayDevices().size() == 1) {
device = models.devices.getReplayDevices().get(0);
DeviceValidationResult cachedResult = models.devices.getCachedValidationStatus(device);
skipDialog = cachedResult.passed || cachedResult.skipped;
skipDialog = cachedResult.passedOrSkipped();
}

if (skipDialog) {
Expand Down
Loading