Merge pull request #160 from SideQuestVR/hotfix/page_crashing

Hotfix/page crashing
This commit is contained in:
SideQuest
2021-12-15 08:46:50 +01:00
committed by GitHub
7 changed files with 50 additions and 41 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
with: with:
node-version: '14' node-version: '14'
- name: "Install dependencies" - name: "Install dependencies"
run: yarn run: yarn install --network-timeout 1000000
- name: "Build application" - name: "Build application"
env: env:
APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ID: ${{ secrets.APPLE_ID }}
+25 -16
View File
@@ -30,6 +30,7 @@ export class AdbClientService {
lastConnectionCheck: number; lastConnectionCheck: number;
deviceStatus: ConnectionStatus = ConnectionStatus.UNAUTHORIZED; deviceStatus: ConnectionStatus = ConnectionStatus.UNAUTHORIZED;
deviceStatusMessage: string = 'Connecting...'; deviceStatusMessage: string = 'Connecting...';
lastErrorMessage: string = '';
pollInterval: number = 1000 * 2; pollInterval: number = 1000 * 2;
savePath: string; savePath: string;
isTransferring: boolean; isTransferring: boolean;
@@ -353,23 +354,31 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
}); });
} }
async setupAdb() { async setupAdb() {
if (!this.isAdbDownloaded()) { try {
await this.appService.seedPlatformTools(); if (!this.isAdbDownloaded()) {
} await this.appService.seedPlatformTools();
this.appService.electron.ipcRenderer.on('adb-command', (event, arg: any) => {
if (this.adbResolves[arg.uuid]) {
if (arg.status && this.adbResolves[arg.uuid].callback) {
this.adbResolves[arg.uuid].callback(arg.status);
} else if (arg.error) {
this.adbResolves[arg.uuid].reject(arg.error);
} else {
this.adbResolves[arg.uuid].resolve(arg.resp);
}
} }
}); this.appService.electron.ipcRenderer.on('adb-command', (event, arg: any) => {
this.adbCommand('setupAdb', { if (this.adbResolves[arg.uuid]) {
adbPath: this.appService.path.join(this.adbPath, this.getAdbBinary()), if (arg.status && this.adbResolves[arg.uuid].callback) {
}); this.adbResolves[arg.uuid].callback(arg.status);
} else if (arg.error) {
this.adbResolves[arg.uuid].reject(arg.error);
} else {
this.adbResolves[arg.uuid].resolve(arg.resp);
}
}
});
this.adbCommand('setupAdb', {
adbPath: this.appService.path.join(this.adbPath, this.getAdbBinary()),
});
this.lastErrorMessage = null;
} catch (e) {
console.error(e);
this.deviceStatus = ConnectionStatus.DISCONNECTED;
this.deviceStatusMessage = 'ADB Setup Error';
this.lastErrorMessage = e.toString();
}
} }
isAdbDownloaded() { isAdbDownloaded() {
try { try {
+1 -1
View File
@@ -5,7 +5,7 @@
<app-loading-spinner #spinner></app-loading-spinner> <app-loading-spinner #spinner></app-loading-spinner>
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar> <app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar>
<webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" [attr.src]="webUrl" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview" partition='webview-partition'></webview> <webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" [attr.src]="webUrl" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview"></webview>
<mz-modal #getHelpModal [fixedFooter]="true"> <mz-modal #getHelpModal [fixedFooter]="true">
<mz-modal-header> <mz-modal-header>
+20 -10
View File
@@ -249,32 +249,42 @@ export class AppService {
return sourcesPath; return sourcesPath;
} }
seedPlatformTools() { seedPlatformTools() {
return new Promise<void>(async resolve => { return new Promise<void>(async (resolve, reject) => {
let sourcesPath = this.getPlatformToolsSeedPath(); let sourcesPath = this.getPlatformToolsSeedPath();
if (sourcesPath == null) { if (sourcesPath == null) {
console.error('Unable to locate platform tools! Try reinstalling sidequest.'); console.error('Unable to locate platform tools! Try reinstalling sidequest.');
resolve(); reject('Unable to locate platform tools! Try reinstalling sidequest.');
return; return;
} }
await this.mkdir(this.path.join(this.appData, 'platform-tools')); await this.mkdir(this.path.join(this.appData, 'platform-tools'));
try { try {
let files = this.fs.readdirSync(sourcesPath); let files: [] = this.fs.readdirSync(sourcesPath);
//always copy the adb executable last so this will retry in the event some copying fails
files.sort((a: string, b) => (a.endsWith('adb') || a.endsWith('adb.exe') ? 1 : -1));
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
this.fs.copyFileSync( try {
this.path.join(sourcesPath, files[i]), this.fs.copyFileSync(
this.path.join(this.appData, 'platform-tools', files[i]) this.path.join(sourcesPath, files[i]),
); this.path.join(this.appData, 'platform-tools', files[i])
);
} catch (e) {
console.error('Error copying platform tools file ' + files[i] + e);
//if the file exists and isn't writeable, don't give up, have some hope it's just in use and is fine.
if (!this.fs.existsSync(this.path.join(this.appData, 'platform-tools', files[i]))) {
throw 'Error copying platform tools file: ' + e.toString();
}
}
} }
if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') { if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') {
this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() => this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() =>
setTimeout(() => resolve(), 5000) setTimeout(() => resolve(), 8000)
); );
} else { } else {
setTimeout(() => resolve(), 5000); setTimeout(() => resolve(), 8000);
} }
} catch (e) { } catch (e) {
console.error('Error seeding platform tools! ', e); console.error('Error seeding platform tools! ', e);
resolve(); reject('Error seeding platform tools: ' + e.toString());
} }
}); });
} }
@@ -222,7 +222,7 @@
arrow_drop_down arrow_drop_down
</i> </i>
<div id="connection-status" class="connection-status-unauthorized" mz-tooltip <div id="connection-status" class="connection-status-unauthorized" mz-tooltip
position="bottom" [ngClass]="adbService.connectionCss" [tooltip]="'Device connection status.'"> position="bottom" [ngClass]="adbService.connectionCss" [tooltip]="adbService.lastErrorMessage||'Device connection status.'">
<div id="connection-status-message" [innerHTML]="appService.versionName+'&nbsp;&nbsp;'+adbService.deviceStatusMessage"></div> <div id="connection-status-message" [innerHTML]="appService.versionName+'&nbsp;&nbsp;'+adbService.deviceStatusMessage"></div>
</div> </div>
</div> </div>
-12
View File
@@ -1,7 +1,6 @@
import { Injectable, isDevMode } from '@angular/core'; import { Injectable, isDevMode } from '@angular/core';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
import { OPEN_IN_SYSTEM_BROWSER_DOMAINS } from '../../../electron/external-urls';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@@ -46,17 +45,6 @@ export class WebviewService {
.bsaber-tooltip.-sidequest-remove::after { .bsaber-tooltip.-sidequest-remove::after {
content: "Remove Custom Level"; content: "Remove Custom Level";
}`; }`;
let ses = this.appService.remote.session.fromPartition('webview-partition');
ses.webRequest.onBeforeRequest((details, callback) => {
let url = details.url;
const extUrl = new URL(url).host.toLowerCase();
if (OPEN_IN_SYSTEM_BROWSER_DOMAINS.includes(extUrl)) {
this.appService.electron.shell.openExternal(url);
callback({ cancel: true });
} else {
callback({});
}
});
this.webView.addEventListener('did-start-loading', e => { this.webView.addEventListener('did-start-loading', e => {
this.isWebviewLoading = true; this.isWebviewLoading = true;
this.webView.insertCSS(customCss); this.webView.insertCSS(customCss);
+2
View File
@@ -15,6 +15,8 @@ const exec = require('child_process').exec;
const crypto = require('crypto'); const crypto = require('crypto');
const request = require('request'); const request = require('request');
const progress = require('request-progress'); const progress = require('request-progress');
//without this, there's a bug in electron that makes facebook pages ruin everything, see https://github.com/electron/electron/issues/25469
app.commandLine.appendSwitch('disable-features', 'CrossOriginOpenerPolicy');
// const Readable = require('stream').Readable; // const Readable = require('stream').Readable;
import { SetPropertiesCommand } from './setproperties'; import { SetPropertiesCommand } from './setproperties';