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

1.10 - android app crash - FuseJS/Storage - breaks on a File.Exists call from Uno #129

Closed
AndrewEQ opened this issue Nov 15, 2018 · 15 comments

Comments

@AndrewEQ
Copy link
Contributor

Hi guys,

Storage.read crashes android app (crashing devices: low-end Android 6, low Android 8.1; works on medium-end Android 6).

I've compiled from latest Uno and using latest Fuselibs.

Repeatable test code:

<App>
	<JavaScript>

	var Storage = require('FuseJS/Storage');
	Storage.read("test.txt")
		.then(function(str) {
			console.log("str: " + str);
		},function(error){
			console.log("Error: " + error);
		});

	</JavaScript>
</App>

I've narrowed it down to File.Exists causing the crash when using Storage.read:
https://github.com/fuse-open/fuselibs/blob/master/Source/Fuse.Storage/ApplicationDir.uno#L36

Strangely, Storage.readSync seems to be working fine.

@kusma
Copy link
Contributor

kusma commented Nov 15, 2018

Is this bug new in 1.10, or can you also reproduce it on 1.9?

@AndrewEQ
Copy link
Contributor Author

Yeah, I believe its a new 1.10 bug; I haven't retested in 1.9 but I think I would have noticed it in 1.9, else I wouldn't have been able to get very far with my app :D

@AndrewEQ
Copy link
Contributor Author

AndrewEQ commented Nov 16, 2018

Ok, I did more testing and here are my notes:

  1. FileSystem.read also breaks if the file does not exist instead of throwing an exception
  2. FileSystem.exists (async) doesn't break! Strange, so I checked the underlying code and the only difference I can think of is the structure? In FileSystem.exists, a "RunTask" is used and in the Storage.read a Promise is used.

FileSystem.exists

public Future<bool> Exists(string path)
{
    return RunTask<string, bool>(ExistsSync, path);
}

Storage.read

public static Future<string> ReadAsync(string filename)
{
    return Promise<string>.Run(new ReadClosure(filename).Invoke);
}

Test app

<App>
	<JavaScript>

		var FileSystem = require("FuseJS/FileSystem");
		var Storage = require('FuseJS/Storage');

		var filename = "testfile1.tmp";
		var path = FileSystem.dataDirectory + "/" + filename;


		FileSystem.exists(path)
		.then(function(x) {
			console.log(x ? "it's there! =)" : "it's missing :/");
		}, function(error) {
			console.log("Unable to check if file exists");
		});



		FileSystem.writeTextToFile(path, "hello world")
		.then(function() {
			return FileSystem.readTextFromFile(path);
		})
		.then(function(text) {
			console.log("The read file content was: " + text);
		})
		.catch(function(error) {
			console.log("Unable to read file due to error:" + error);
		});


		Storage.read(filename)
		.then(function(str) {
			console.log("str: " + str);
		},function(error){
			console.log("Error: " + error);
		});



		FileSystem.readTextFromFile(FileSystem.dataDirectory + "/" + "testfile2.tmp")
		.then(function(contents) {
			console.log('contents');
			console.log(contents);
		}, function(error) {
			console.log('error');
			console.log(error);
		});
	</JavaScript>
</App>

@AndrewEQ
Copy link
Contributor Author

Oh yeah, I retested on 1.9 and it doesn't crash.

@kusma
Copy link
Contributor

kusma commented Nov 16, 2018

TBH, this sounds a bit like the good old "throwing exceptions inside V8 crashes"-problem. So my guess is that some exception has been introduced... Would it be possible for you to debug this a bit, and try to confirm? If so, it might be possible to at least get an emergency-switch to disable the native stacktrace-stuff, so people can choose what what is broken? :P

@kusma
Copy link
Contributor

kusma commented Nov 16, 2018

I'm talking about this issue: fuse-open/fuselibs#679

@AndrewEQ
Copy link
Contributor Author

Lol, so what happened between 1.9 and 1.10 to cause this crashing(fuse-open/fuselibs#679)? Can't "we" fix that rather? XD

Anyhoo, I did do further debugging and can confirm its the throwing of the exception here(or read below): https://github.com/fuse-open/fuselibs/blob/master/Source/Fuse.Storage/ApplicationDir.uno#L52
I returned true from the TryRead function and it didn't crash, as soon as I returned false, the app died.

		public static string Read(string filename)
		{
			string content;
			if (TryRead(filename, out content))
				return content;
			else
				throw new Exception("File does not exist.");
		}

FileSystem.exists doesn't throw an exception when the file doesn't exist, it just returns the result of the File.Exists and thats why it didn't cause a crash: https://github.com/fuse-open/fuselibs/blob/master/Source/Fuse.FileSystem/FileSystemOperations.uno#L75

		public bool ExistsSync(string path)
		{
			// File.Exists also returns true special files like named pipes etc in .NET (mono and MS implementation)
			// and also in uBase::Disk->IsFile. This makes the following work for all file system entries:
			return File.Exists(path) || Directory.Exists(path);
		}

@mortend
Copy link
Member

mortend commented Dec 1, 2018

I have a branch on my fuselibs fork that possibly fixes both this crash and fuse-open/fuselibs#679.

https://github.com/mortend/fuselibs/tree/upgrade-v8

My branch isn't ready for merging yet, but can be used to test if a new V8 build fixes the problem(s).

@AndrewEQ
Copy link
Contributor Author

@mortend cool, I will try it out sometime soon.

@AndrewEQ
Copy link
Contributor Author

Thanks @mortend it seems have resolved the issue and is working so far, will be doing more testing in the New Year and will keep ya posted.

@ckarmy
Copy link
Contributor

ckarmy commented Jan 23, 2019

This solve the Android crash problems

@Hotschmoe
Copy link

Hotschmoe commented Jan 26, 2019

I tried the above Source change to mortend's fork but I am still receiving the following crash when launching on android

Launching activity 'SASi'

Running logcat on 380f7dc7

01-26 01:08:22.286  1079  1726 I ActivityManager: Start proc 27390:com.apps.sasi/u0a170 for activity com.apps.sasi/.SASi
01-26 01:08:22.307 27390 27390 I zygote  : Late-enabling -Xcheck:jni
01-26 01:08:22.405 27390 27390 D FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
01-26 01:08:22.408 27390 27390 I FirebaseInitProvider: FirebaseApp initialization successful
01-26 01:08:22.420 27390 27390 D SASi    : SDK: 27
01-26 01:08:22.439 27390 27416 I FA      : App measurement is starting up, version: 12211
01-26 01:08:22.440 27390 27416 I FA      : To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
01-26 01:08:22.440 27390 27416 I FA      : To enable faster debug mode event logging run:
01-26 01:08:22.440 27390 27416 I FA      :   adb shell setprop debug.firebase.analytics.app com.apps.sasi
01-26 01:08:22.459 27390 27390 I Adreno  : QUALCOMM build                   : 9c9b012, I92eb381bc9
01-26 01:08:22.459 27390 27390 I Adreno  : Build Date                       : 12/31/17
01-26 01:08:22.459 27390 27390 I Adreno  : OpenGL ES Shader Compiler Version: EV031.22.00.01
01-26 01:08:22.459 27390 27390 I Adreno  : Local Branch                     :
01-26 01:08:22.459 27390 27390 I Adreno  : Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.6.4.R1.08.00.00.309.049
01-26 01:08:22.459 27390 27390 I Adreno  : Remote Branch                    : NONE
01-26 01:08:22.459 27390 27390 I Adreno  : Reconstruct Branch               : NOTHING
01-26 01:08:22.462 27390 27390 I Adreno  : PFP: 0x005ff087, ME: 0x005ff063
01-26 01:08:22.464 27390 27390 I zygote  : android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
01-26 01:08:22.578 27390 27390 D AutoManageHelper: starting AutoManage for client 0 false null
01-26 01:08:22.593 27390 27390 W MediaPlayer: Use of stream types is deprecated for operations other than volume control
01-26 01:08:22.593 27390 27390 W MediaPlayer: See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-26 01:08:22.595 27390 27390 V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
01-26 01:08:22.595 27390 27390 V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
01-26 01:08:22.595   815  1868 D NuPlayerDriver: NuPlayerDriver(0xecdbd580) created, clientPid(27390)
01-26 01:08:22.603 27390 27390 D AutoManageHelper: onStart true {0=com.google.android.gms.common.api.internal.zzi$zza@b8adffb}
01-26 01:08:22.625 27390 27440 D OpenGLRenderer: HWUI GL Pipeline
01-26 01:08:22.662 27390 27440 I OpenGLRenderer: Initialized EGL, version 1.4
01-26 01:08:22.662 27390 27440 D OpenGLRenderer: Swap behavior 2
01-26 01:08:22.695 27390 27390 W AudioManager: Use of stream types is deprecated for operations other than volume control
01-26 01:08:22.695 27390 27390 W AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-26 01:08:22.698  1079  2982 I MediaFocusControl: requestAudioFocus() from uid/pid 10170/27390 clientId=android.media.AudioManager@41b3cf callingPack=com.apps.sasi req=1 flags=0x0 sdk=26
01-26 01:08:22.705 27390 27397 I zygote  : Do partial code cache collection, code=30KB, data=21KB
01-26 01:08:22.706 27390 27397 I zygote  : After code cache collection, code=30KB, data=21KB
01-26 01:08:22.706 27390 27397 I zygote  : Increasing code cache capacity to 128KB

01-26 01:08:22.751 27390 27463 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7 in tid 27463 (Thread-4), pid 27390 (com.apps.sasi)
01-26 01:08:22.760 27390 27466 W GrallocMapperPassthrough: buffer descriptor with invalid usage bits 0x2000
01-26 01:08:22.763 27390 27466 W GrallocMapperPassthrough: buffer descriptor with invalid usage bits 0x2000
01-26 01:08:22.765 27390 27411 W GrallocMapperPassthrough: buffer descriptor with invalid usage bits 0x2000
01-26 01:08:22.767 27390 27411 W GrallocMapperPassthrough: buffer descriptor with invalid usage bits 0x2000
01-26 01:08:22.774 27390 27411 W GrallocMapperPassthrough: buffer descriptor with invalid usage bits 0x2000
01-26 01:08:22.775 27390 27411 W GrallocMapperPassthrough: buffer descriptor with invalid usage bits 0x2000

01-26 01:08:22.819   836   836 I /system/bin/tombstoned: received crash request for pid 27390
01-26 01:08:22.820 27470 27470 I crash_dump32: performing dump of process 27390 (target tid = 27463)
01-26 01:08:22.822 27470 27470 F DEBUG   : pid: 27390, tid: 27463, name: Thread-4  >>> com.apps.sasi <<<

01-26 01:08:23.443  1079  2982 I ActivityManager: Process com.apps.sasi (pid 27390) has died: fore TOP
01-26 01:08:23.444  1079  1100 W zygote64: kill(-27390, 9) failed: No such process
01-26 01:08:23.447   695   695 I Zygote  : Process 27390 exited due to signal (11)

01-26 01:08:23.480  1079  1105 W ActivityManager: setHasOverlayUi called on unknown pid: 27390
01-26 01:08:23.490  1079  1100 W zygote64: kill(-27390, 9) failed: No such process
01-26 01:08:23.490  1079  1100 I zygote64: Successfully killed process cgroup uid 10170 pid 27390 in 45ms

Unknown Logcat Error: raised from 'adb -s 380f7dc7 logcat'

@Hotschmoe
Copy link

Hotschmoe commented Jan 26, 2019

this was the crash log before i switched to mortend's fork

01-26 00:48:54.016  1079  2834 I ActivityManager: Start proc 26443:com.apps.sasi/u0a170 for activity com.apps.sasi/.SASi
01-26 00:48:54.023 26443 26443 I zygote  : Late-enabling -Xcheck:jni
01-26 00:48:54.147 26443 26443 D FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
01-26 00:48:54.151 26443 26443 I FirebaseInitProvider: FirebaseApp initialization successful
01-26 00:48:54.169 26443 26443 D SASi    : SDK: 27
01-26 00:48:54.187 26443 26465 I FA      : App measurement is starting up, version: 12211
01-26 00:48:54.187 26443 26465 I FA      : To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
01-26 00:48:54.188 26443 26465 I FA      : To enable faster debug mode event logging run:
01-26 00:48:54.188 26443 26465 I FA      :   adb shell setprop debug.firebase.analytics.app com.apps.sasi
01-26 00:48:54.205 26443 26443 I Adreno  : QUALCOMM build                   : 9c9b012, I92eb381bc9
01-26 00:48:54.205 26443 26443 I Adreno  : Build Date                       : 12/31/17
01-26 00:48:54.205 26443 26443 I Adreno  : OpenGL ES Shader Compiler Version: EV031.22.00.01
01-26 00:48:54.205 26443 26443 I Adreno  : Local Branch                     :
01-26 00:48:54.205 26443 26443 I Adreno  : Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.6.4.R1.08.00.00.309.049
01-26 00:48:54.205 26443 26443 I Adreno  : Remote Branch                    : NONE
01-26 00:48:54.205 26443 26443 I Adreno  : Reconstruct Branch               : NOTHING
01-26 00:48:54.207 26443 26443 I Adreno  : PFP: 0x005ff087, ME: 0x005ff063
01-26 00:48:54.214 26443 26443 I zygote  : android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
01-26 00:48:54.328 26443 26443 D AutoManageHelper: starting AutoManage for client 0 false null
01-26 00:48:54.332 26443 26448 I zygote  : Do partial code cache collection, code=30KB, data=18KB
01-26 00:48:54.332 26443 26448 I zygote  : After code cache collection, code=27KB, data=17KB
01-26 00:48:54.332 26443 26448 I zygote  : Increasing code cache capacity to 128KB
01-26 00:48:54.350 26443 26443 W MediaPlayer: Use of stream types is deprecated for operations other than volume control
01-26 00:48:54.350 26443 26443 W MediaPlayer: See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-26 00:48:54.351 26443 26443 V MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
01-26 00:48:54.351 26443 26443 V MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
01-26 00:48:54.352   815  9835 D NuPlayerDriver: NuPlayerDriver(0xecdbdb80) created, clientPid(26443)
01-26 00:48:54.362 26443 26443 D AutoManageHelper: onStart true {0=com.google.android.gms.common.api.internal.zzi$zza@b8adffb}
01-26 00:48:54.384 26443 26490 D OpenGLRenderer: HWUI GL Pipeline
01-26 00:48:54.420 26443 26490 I OpenGLRenderer: Initialized EGL, version 1.4
01-26 00:48:54.420 26443 26490 D OpenGLRenderer: Swap behavior 2
01-26 00:48:54.452 26443 26443 W AudioManager: Use of stream types is deprecated for operations other than volume control
01-26 00:48:54.452 26443 26443 W AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-26 00:48:54.454  1079 24399 I MediaFocusControl: requestAudioFocus() from uid/pid 10170/26443 clientId=android.media.AudioManager@41b3cf callingPack=com.apps.sasi req=1 flags=0x0 sdk=26
01-26 00:48:54.466 26443 26493 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7 in tid 26493 (Thread-4), pid 26443 (com.apps.sasi)
01-26 00:48:54.532   836   836 I /system/bin/tombstoned: received crash request for pid 26443
01-26 00:48:54.534 26512 26512 I crash_dump32: performing dump of process 26443 (target tid = 26493)
01-26 00:48:54.535 26512 26512 F DEBUG   : pid: 26443, tid: 26493, name: Thread-4  >>> com.apps.sasi <<<

01-26 00:48:55.283   784   784 E lowmemorykiller: Error writing /proc/26443/oom_score_adj; errno=22
01-26 00:48:55.300  1079 24400 I ActivityManager: Process com.apps.sasi (pid 26443) has died: vis  +99TOP
01-26 00:48:55.300  1079  1100 W zygote64: kill(-26443, 9) failed: No such process
01-26 00:48:55.300  1079  1100 I zygote64: Successfully killed process cgroup uid 10170 pid 26443 in 0ms
01-26 00:48:55.305   695   695 I Zygote  : Process 26443 exited due to signal (11)
01-26 00:48:55.318  1079  1105 W ActivityManager: setHasOverlayUi called on unknown pid: 26443

mortend added a commit to mortend/fuselibs that referenced this issue Jan 26, 2019
This upgrades to a more recent version of V8 on Android.

Because the new version of V8 removes some debug functionality, this
functionality is also removed from the V8Simple interface.

Because we now compile V8Simple and embed V8 static libraries into
the app, V8Simple and V8 now use the same standard library as the
rest of the app. This seems to fix crashes when getting an exception
inside V8 on Android.

- fuse-open#679
- fuse-open/uno#129
@Hotschmoe
Copy link

i switched to the new master now that the upgrade to V8 was merged and my app works, (I didn't have nuget so that may be why it failed last night).

Thanks for the hard works guys!

@mortend
Copy link
Member

mortend commented Jan 28, 2019

Closing the issue because it sounds like the Android crashes have been fixed.

@mortend mortend closed this as completed Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants