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

java.lang.RuntimeExceptionJSONTokener.java:449 An error occurred while executing doInBackground() #1507

Closed
iAladdin opened this issue Jan 23, 2019 · 12 comments

Comments

@iAladdin
Copy link

I am using bugsnag as my crash reporter.
And I got this crash:

I think maybe code-push download file broken because of network issues or app was killed? What should I do about this kind of scenario?

Thank you!

Steps to Reproduce

  1. I don't know what happened.

Expected Behavior

What you expected to happen?

A crash report by bugsnag

Actual Behavior

What actually happens?

java.lang.RuntimeException · An error occurred while executing doInBackground()
AsyncTask.java:354android.os.AsyncTask$3.done	
FutureTask.java:383java.util.concurrent.FutureTask.finishCompletion	
FutureTask.java:252java.util.concurrent.FutureTask.setException	
FutureTask.java:271java.util.concurrent.FutureTask.run	
ThreadPoolExecutor.java:1167java.util.concurrent.ThreadPoolExecutor.runWorker	
ThreadPoolExecutor.java:641java.util.concurrent.ThreadPoolExecutor$Worker.run	
Thread.java:764java.lang.Thread.run	
Caused By: com.microsoft.codepush.react.CodePushMalformedDataException · Unable to parse contents of /data/user/0/io.ddex.wallet/files/CodePush/codepush.json, the file may be corrupted.
CodePushUtils.java:200com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile	
CodePushUpdateManager.java:55com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo	
CodePushUpdateManager.java:105com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash	
CodePushUpdateManager.java:115com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackage	
CodePushNativeModule.java:307com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
CodePushNativeModule.java:303com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
AsyncTask.java:333android.os.AsyncTask$2.call	
FutureTask.java:266java.util.concurrent.FutureTask.run	
ThreadPoolExecutor.java:1167java.util.concurrent.ThreadPoolExecutor.runWorker	
ThreadPoolExecutor.java:641java.util.concurrent.ThreadPoolExecutor$Worker.run	
Thread.java:764java.lang.Thread.run	
Caused By: org.json.JSONException · End of input at character 0 of
JSONTokener.java:449org.json.JSONTokener.syntaxError	
JSONTokener.java:97org.json.JSONTokener.nextValue	
JSONObject.java:159org.json.JSONObject.<init>	
JSONObject.java:176org.json.JSONObject.<init>	
CodePushUtils.java:197com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile	
CodePushUpdateManager.java:55com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo	
CodePushUpdateManager.java:105com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash	
CodePushUpdateManager.java:115com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackage	
CodePushNativeModule.java:307com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
CodePushNativeModule.java:303com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
AsyncTask.java:333android.os.AsyncTask$2.call	
FutureTask.java:266java.util.concurrent.FutureTask.run	
ThreadPoolExecutor.java:1167java.util.concurrent.ThreadPoolExecutor.runWorker	
ThreadPoolExecutor.java:641java.util.concurrent.ThreadPoolExecutor$Worker.run	
Thread.java:764java.lang.Thread.run
java.lang.RuntimeException · An error occurred while executing doInBackground()
AsyncTask.java:354android.os.AsyncTask$3.done	
FutureTask.java:383java.util.concurrent.FutureTask.finishCompletion	
FutureTask.java:252java.util.concurrent.FutureTask.setException	
FutureTask.java:271java.util.concurrent.FutureTask.run	
ThreadPoolExecutor.java:1167java.util.concurrent.ThreadPoolExecutor.runWorker	
ThreadPoolExecutor.java:641java.util.concurrent.ThreadPoolExecutor$Worker.run	
Thread.java:764java.lang.Thread.run	
Caused By: com.microsoft.codepush.react.CodePushMalformedDataException · Unable to parse contents of /data/user/0/io.ddex.wallet/files/CodePush/codepush.json, the file may be corrupted.
CodePushUtils.java:200com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile	
CodePushUpdateManager.java:55com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo	
CodePushUpdateManager.java:105com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash	
CodePushUpdateManager.java:115com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackage	
CodePushNativeModule.java:307com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
CodePushNativeModule.java:303com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
AsyncTask.java:333android.os.AsyncTask$2.call	
FutureTask.java:266java.util.concurrent.FutureTask.run	
ThreadPoolExecutor.java:1167java.util.concurrent.ThreadPoolExecutor.runWorker	
ThreadPoolExecutor.java:641java.util.concurrent.ThreadPoolExecutor$Worker.run	
Thread.java:764java.lang.Thread.run	
Caused By: org.json.JSONException · End of input at character 0 of
JSONTokener.java:449org.json.JSONTokener.syntaxError	
JSONTokener.java:97org.json.JSONTokener.nextValue	
JSONObject.java:159org.json.JSONObject.<init>	
JSONObject.java:176org.json.JSONObject.<init>	
CodePushUtils.java:197com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile	
CodePushUpdateManager.java:55com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo	
CodePushUpdateManager.java:105com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash	
CodePushUpdateManager.java:115com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackage	
CodePushNativeModule.java:307com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
CodePushNativeModule.java:303com.microsoft.codepush.react.CodePushNativeModule$4.doInBackground	
AsyncTask.java:333android.os.AsyncTask$2.call	
FutureTask.java:266java.util.concurrent.FutureTask.run	
ThreadPoolExecutor.java:1167java.util.concurrent.ThreadPoolExecutor.runWorker	
ThreadPoolExecutor.java:641java.util.concurrent.ThreadPoolExecutor$Worker.run	
Thread.java:764java.lang.Thread.run

Environment

  • react-native-code-push version: 5.5.0
  • react-native version: 0.57.8
  • iOS/Android/Windows version: Android 9
  • Does this reproduce on a debug build or release build? release
  • Does this reproduce on a simulator, or only on a physical device? physical device.
@iAladdin
Copy link
Author

I checked issue #1257
But I think they are different issues. So I open this.

@yuri-kulikov
Copy link
Contributor

Hi @iAladdin,
Thanks for reporting!

It looks like there are some problems during getting info from /files/CodePush/codepush.json (in CodePushUpdateManager.getCurrentPackageInfo).
How often does this happen? Is this a rare incident or something recurring?
Can you also clarify how you use CodePush in your project?

@iAladdin
Copy link
Author

Hi @yuri-kulikov,

How often does this happen?

12.5% of our users codepush update failed and rollback to last version. (data from appcenter portal)
And I have 2 bug report from bugsnag in recently 2 days. I'll keep eyes on the report portal.

Is this a rare incident or something recurring?

I think roughly 1% user will face this problem. (data from appcenter analytics portal)

Can you also clarify how you use CodePush in your project?

sure.
React Native Code:

// under RootAppComponent
codePush.allowRestart();
const codePushOptions = {
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  installMode: codePush.InstallMode.ON_NEXT_RESTART,
  updateDialog: false,
};

let CodePushApp;
if (__DEV__) {
  CodePushApp = App;
} else {
  CodePushApp = codePush(codePushOptions)(App);
}

Other operation about codepush just npm install and react-native link

@yuri-kulikov
Copy link
Contributor

Hi @iAladdin,
Sorry for the delay!

We have found that there's a similar unresolved issue #1149 and we will try to investigate it more deeply. Please let us know if you find out anything related to this issue, it would help us a lot!

@iAladdin
Copy link
Author

iAladdin commented Feb 1, 2019

@yuri-kulikov

Sure, I'll follow this issue too.
If I found anything I'll comment it here.

@sridhard
Copy link

sridhard commented Mar 4, 2019

Hi

Any update on this issue. Approximately 5% of our users are facing this issue

@yuri-kulikov
Copy link
Contributor

Hey, @sridhard
Thanks for reporting!

  1. Can you please also clarify how you use CodePush?
  2. Can you reproduce this issue yourself?

I tried to reproduce it, but unfortunately it did not work. If you can share any new details, we would really appreciate it!

@sridhard
Copy link

sridhard commented Mar 5, 2019

@yuri-kulikov

I am not able to reproduce myself. We have integrated bugsnag in our app and many users face this issue. If you need any specific logs we can add in our app and collect the logs.

Below is our codepush code:
const codePushOptions = {
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
mandatoryInstallMode: CodePush.InstallMode.ON_NEXT_RESUME,
};
CodePush.sync(
codePushOptions,
this.codePushStatusDidChange.bind(this),
this.codePushDownloadDidProgress.bind(this),
);

codePushStatusDidChange(syncStatus) {
switch (syncStatus) {
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.CHECKING_FOR_UPDATE');
break;
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
break;
case CodePush.SyncStatus.INSTALLING_UPDATE:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.INSTALLING_UPDATE');
break;
case CodePush.SyncStatus.UP_TO_DATE:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.UP_TO_DATE');
break;
case CodePush.SyncStatus.UPDATE_INSTALLED:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.UPDATE_INSTALLED');
break;
case CodePush.SyncStatus.SYNC_IN_PROGRESS:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.SYNC_IN_PROGRESS');
break;
case CodePush.SyncStatus.UNKNOWN_ERROR:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.unknown_error');
break;
case CodePush.SyncStatus.AWAITING_USER_ACTION:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.AWAITING_USER_ACTION');
break;
case CodePush.SyncStatus.UPDATE_IGNORED:
console.log('codePushStatusDidChange', 'CodePush.SyncStatus.UPDATE_IGNORED');
break;
default:
break;
}
CodePush.getUpdateMetadata().then((metadata) => {
global.codePushData = metadata ? { label: metadata.label, version: metadata.appVersion, description: metadata.description } : '';
});
}

codePushDownloadDidProgress(progress) {}

@sridhard
Copy link

sridhard commented Mar 5, 2019

Below is the callstack information:

com.microsoft.codepush.react.CodePushMalformedDataException · Unable to parse contents of /data/user/0/com.coursavy.test/files/CodePush/codepush.json, the file may be corrupted.
CodePushUtils.java:198com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile
CodePushUpdateManager.java:55com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo
CodePushUpdateManager.java:105com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash
CodePushNativeModule.java:525com.microsoft.codepush.react.CodePushNativeModule.isFirstRun
Method.java:-2java.lang.reflect.Method.invoke
JavaMethodWrapper.java:372com.facebook.react.bridge.JavaMethodWrapper.invoke
JavaModuleWrapper.java:160com.facebook.react.bridge.JavaModuleWrapper.invoke
NativeRunnable.java:-2com.facebook.react.bridge.queue.NativeRunnable.run
Handler.java:739android.os.Handler.handleCallback
Handler.java:95android.os.Handler.dispatchMessage
MessageQueueThreadHandler.java:29com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
Looper.java:148android.os.Looper.loop
MessageQueueThreadImpl.java:192com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
Thread.java:818java.lang.Thread.run
Caused By: org.json.JSONException · End of input at character 0 of
JSONTokener.java:449org.json.JSONTokener.syntaxError
JSONTokener.java:97org.json.JSONTokener.nextValue
JSONObject.java:156org.json.JSONObject.
JSONObject.java:173org.json.JSONObject.
CodePushUtils.java:195com.microsoft.codepush.react.CodePushUtils.getJsonObjectFromFile
CodePushUpdateManager.java:55com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageInfo
CodePushUpdateManager.java:105com.microsoft.codepush.react.CodePushUpdateManager.getCurrentPackageHash
CodePushNativeModule.java:525com.microsoft.codepush.react.CodePushNativeModule.isFirstRun
Method.java:-2java.lang.reflect.Method.invoke
JavaMethodWrapper.java:372com.facebook.react.bridge.JavaMethodWrapper.invoke
JavaModuleWrapper.java:160com.facebook.react.bridge.JavaModuleWrapper.invoke
NativeRunnable.java:-2com.facebook.react.bridge.queue.NativeRunnable.run
Handler.java:739android.os.Handler.handleCallback
Handler.java:95android.os.Handler.dispatchMessage
MessageQueueThreadHandler.java:29com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
Looper.java:148android.os.Looper.loop
MessageQueueThreadImpl.java:192com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
Thread.java:818java.lang.Thread.run

@yuri-kulikov
Copy link
Contributor

@sridhard, thanks for the details! You can try to use workaround suggested here, until we fix this issue.

@yuri-kulikov
Copy link
Contributor

Hey @iAladdin, @sridhard
We've fixed the issue in the new version of react-native-code-push (5.6.0).

I'll close the issue for now, but feel free to ask any questions or reopen this issue if needed!

@Gustash
Copy link

Gustash commented Nov 4, 2019

I have this issue happening again in 5.6.1. Let me know what you need from me for you to be able to take a look at it again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants