Blockstack Android API 0.4.1 Writes to GAIA Failing


#1

@friedger, @jude

I’m seeing I/O problems writing to GAIA with the latest version of the Blockstack Android API 0.4.1 when calling putFile. We’ve been using a javascript class that does indexing by sequentially reading an index, then re-writing it encrypted for different parties and finally writing the files tracked in the index. This has worked fine through multiple releases on multiple platforms but seems to be failing in the new Android API (it worked in the previous one).

To try and track things down, first stepped through the code with the Chrome/Android Studio debuggers on device, but that didn’t really yield any information (i.e. I wasn’t able to see the code emerge in the promise resolution or rejection for a file write, nor was I able to see any exceptions get thrown or caught).

That led me to insert a boatload of debug statements into the code from our javascript, through react-native, to the android-sdk and finally to the blockstack javascript executed on v8. What I’m seeing is that some of our calls from the Stealthy indexer never same to make it into connectToGaiaHub. Consider the first successful trace of calls below for the file ‘relay.id/conversations/offline/sharedIndex.json’:

DEBUG(blockstack_android::putFile): calling userSession.putfile with relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack.js::putFile): called on relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack.js::putFileImpl): called on relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack.js::putFileImpl): calling getOrSetLocalGaiaHubConnection for relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack.js::getOrSetLocalGaiaHubConnection): calling with relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack.js::getOrSetLocalGaiaHubConnection): returning call to setLocalGaiaHubConnection (path = relay.id/conversations/offline/sharedIndex.json).
DEBUG(blockstack.js::setLocalGaiaHubConnection): called (path = relay.id/conversations/offline/sharedIndex.json).
DEBUG(blockstack.js::setLocalGaiaHubConnection): returing call to connectToGaiaHub (path = relay.id/conversations/offline/sharedIndex.json).
DEBUG(blockstack.js::setLocalGaiaHubConnection): in then for connectToGaiaHub result (path = relay.id/conversations/offline/sharedIndex.json).
DEBUG(blockstack.js::putFileImpl): calling uploadToGaiaHub for relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack.js::uploadToGaiaHub): calling fetch for relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack.js::uploadToGaiaHub): fetch for relay.id/conversations/offline/sharedIndex.json returning(1)
DEBUG(blockstack.js::uploadToGaiaHub): fetch for relay.id/conversations/offline/sharedIndex.json returning(2)
DEBUG(blockstack.js::uploadToGaiaHub): fetch for relay.id/conversations/offline/sharedIndex.json returning(3) https://gaia.blockstack.org/hub/1CHxCak1UKFYutLLeVseNPgNa2ZBKExtQG/relay.id/conversations/offline/sharedIndex.json
DEBUG(blockstack_android::putFile): calling userSession.putfile result callback with https://gaia.blockstack.org/hub/1CHxCak1UKFYutLLeVseNPgNa2ZBKExtQG/relay.id/conversations/offline/sharedIndex.json

Now look at this unsucessful trace of calls for the file ‘relay.id/conversations/offline/index.json’:

DEBUG(blockstack_android::putFile): calling userSession.putfile with relay.id/conversations/offline/index.json
DEBUG(blockstack.js::putFile): called on relay.id/conversations/offline/index.json
DEBUG(blockstack.js::putFileImpl): called on relay.id/conversations/offline/index.json
DEBUG(blockstack.js::putFileImpl): calling getOrSetLocalGaiaHubConnection for relay.id/conversations/offline/index.json
DEBUG(blockstack.js::getOrSetLocalGaiaHubConnection): calling with relay.id/conversations/offline/index.json
DEBUG(blockstack.js::getOrSetLocalGaiaHubConnection): returning call to setLocalGaiaHubConnection (path = relay.id/conversations/offline/index.json).
DEBUG(blockstack.js::setLocalGaiaHubConnection): called (path = relay.id/conversations/offline/index.json).
DEBUG(blockstack.js::setLocalGaiaHubConnection): returing call to connectToGaiaHub (path = relay.id/conversations/offline/index.json).

You can see the logging code/modified android-sdk code here that corresponds to the messages above: https://github.com/AC-FTW/blockstack-android (branch master, commit 3407ab7)

I’ve also attached the complete Android Studio debug log corresponding to the above log snippets to this forum post.AndroidStudioLog.zip (6.6 KB)


#2

Fixed: https://github.com/blockstack/blockstack-android/issues/118