git ssb

1+

Daan Patchwork / manyverse



Commit 512b2390ea6bd8bd486e5351ab0779d9e01a3999

ux: improve crash detection and reports

Andre Staltz committed on 5/9/2019, 2:32:16 PM
Parent: 9f71cca3640954e6da00bd4f73fd0363dcf599e2

Files changed

android/app/build.gradlechanged
android/app/src/main/java/se/manyver/MainActivity.javachanged
package-lock.jsonchanged
package.jsonchanged
patches/nodejs-mobile-react-native+0.4.1.patchadded
src/backend/loader.tschanged
android/app/build.gradleView
@@ -166,9 +166,9 @@
166166 }
167167 }
168168 }
169169
170-def acraVersion = '5.1.3'
170+def acraVersion = '5.3.0'
171171
172172 dependencies {
173173 implementation "ch.acra:acra-core:$acraVersion"
174174 implementation "ch.acra:acra-mail:$acraVersion"
@@ -198,8 +198,11 @@
198198 }
199199 implementation("com.android.support:design:${rootProject.ext.supportLibVersion}") {
200200 force = true
201201 }
202+ implementation("com.android.support:support-fragment:${rootProject.ext.supportLibVersion}") {
203+ force = true
204+ }
202205 implementation("com.facebook.react:react-native:+") {
203206 force = true
204207 }
205208 implementation 'com.facebook.fresco:animated-gif:1.3.0'
android/app/src/main/java/se/manyver/MainActivity.javaView
@@ -25,8 +25,10 @@
2525 import com.facebook.react.modules.core.DeviceEventManagerModule;
2626 import com.facebook.react.uimanager.util.ReactFindViewUtil;
2727 import com.reactnativenavigation.NavigationActivity;
2828
29+import org.acra.ACRA;
30+
2931 public class MainActivity extends NavigationActivity {
3032
3133 private RNNodeJsMobileModule nodejsModule;
3234
@@ -72,8 +74,13 @@
7274 manager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
7375 @Override
7476 public void onReactContextInitialized(ReactContext context) {
7577 nodejsModule = context.getNativeModule(RNNodeJsMobileModule.class);
78+ nodejsModule.setJsExceptionInvokable(new RNNodeJsMobileModule.Invokable<String>() {
79+ public void invoke(String ex) {
80+ ACRA.getErrorReporter().handleException(new Exception(ex));
81+ }
82+ });
7683 try {
7784 nodejsModule.startNodeProject("loader.js", Arguments.createMap());
7885 } catch (Exception e) {
7986 Log.e("NODEJS-RN", "startNodeProject failed to run loader.js");
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 1087636 bytes
New file size: 1088169 bytes
package.jsonView
@@ -128,5 +128,5 @@
128128 "react-native": {
129129 "os": "@staltz/react-native-os",
130130 "rn-viewpager": "@staltz/rn-viewpager"
131131 }
132-}
132+}
patches/nodejs-mobile-react-native+0.4.1.patchView
@@ -1,0 +1,39 @@
1+patch-package
2+--- a/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java
3++++ b/node_modules/nodejs-mobile-react-native/android/src/main/java/com/janeasystems/rn_nodejs_mobile/RNNodeJsMobileModule.java
4+@@ -45,6 +45,11 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements
5+ private static String builtinModulesPath;
6+ private static String nativeAssetsPath;
7+
8++ public interface Invokable<T> {
9++ public void invoke(T param);
10++ }
11++
12++ private static Invokable<String> jsExceptionInvokable;
13+ private static long lastUpdateTime = 1;
14+ private static long previousLastUpdateTime = 0;
15+ private static Semaphore initSemaphore = new Semaphore(1);
16+@@ -91,6 +96,10 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements
17+ asyncInit();
18+ }
19+
20++ public void setJsExceptionInvokable(Invokable<String> i) {
21++ jsExceptionInvokable = i;
22++ }
23++
24+ private void asyncInit() {
25+ if (wasAPKUpdated()) {
26+ try {
27+@@ -243,6 +236,12 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements
28+ final RNNodeJsMobileModule _moduleInstance = _instance;
29+ final String _channelNameToPass = new String(channelName);
30+ final String _msgToPass = new String(msg);
31++ if (jsExceptionInvokable != null) {
32++ if (_msgToPass.matches("^\\{\"event\":\"exception\",\"payload\":\".*")) {
33++ final String _exception = _msgToPass.substring(35, _msgToPass.length() - 5);
34++ jsExceptionInvokable.invoke(_exception);
35++ }
36++ }
37+ new Thread(new Runnable() {
38+ @Override
39+ public void run() {
src/backend/loader.tsView
@@ -7,10 +7,33 @@
77 import os = require('os');
88 const path = require('path');
99 const rnBridge = require('rn-bridge');
1010
11+// Set default directory
1112 const nodejsProjectDir = path.resolve(rnBridge.app.datadir(), 'nodejs-project');
1213 os.homedir = () => nodejsProjectDir;
1314 process.cwd = () => nodejsProjectDir;
15+
16+// Force libsodium to use a WebAssembly implementation
1417 process.env = process.env || {};
15-process.env.CHLORIDE_JS = 'yes'; // Use WebAssembly libsodium
18+process.env.CHLORIDE_JS = 'yes';
19+
20+// Report JS backend crashes to Java, and in turn, to ACRA
21+process.on('uncaughtException', err => {
22+ if (typeof err === 'string') {
23+ rnBridge.channel.post('exception', err);
24+ } else {
25+ rnBridge.channel.post('exception', err.message + '\n' + err.stack);
26+ }
27+ setTimeout(() => {
28+ process.exit(1);
29+ });
30+});
31+const _removeAllListeners = process.removeAllListeners;
32+process.removeAllListeners = function removeAllListeners(eventName: string) {
33+ if (eventName !== 'uncaughtException') {
34+ return _removeAllListeners.call(this, eventName);
35+ }
36+ return process;
37+};
38+
1639 require('./index');

Built with git-ssb-web