Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27753] Android: Random crashes on app start (SDK 9 regression)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 9.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterHans Knöchel
AssigneeJoshua Quick
Created2020-02-07T11:52:52.000+0000
Updated2020-02-11T01:53:28.000+0000

Description

We noticed random crashes during app start when migrating to SDK 9. It can be reproduced in our app thats available to the team by opening it a few times. It crashes around 3 of 10 times. Note: We already had a V8 error log in SDK 8.x that have become worse in SDK 9:
[ERROR] ProxyFactory: Exception thrown while creating V8 proxy.
[ERROR] V8Exception: Exception occurred at undefined:0: Uncaught TypeError: object is not a constructor
We can't seem to find an issue on our end since it works on both iOS and Android.

Comments

  1. Joshua Quick 2020-02-08

    [~hknoechel], I can't reproduce this issue with your app. I tried running it and quitting it (by swiping it off recents list) and starting it again about 10 times on a physical Android 10.0 and Android 6.0 devices. I also tried enabling the "Don't keep activities" option under the Android OS' "Developer Options" (causes OS to destroy and recreate activities in back-stack) and it restarted just fine. The error message suggests that the code is attempting to create an object while the V8 runtime isn't running. That's why it prints "undefined:0" where it should be printing "jsFileName:lineNumber". If you're willing, try this. Go to the below source file. The code within the if-condition is where the error message is happening. [./android/runtime/v8/src/native/ProxyFactory.cpp#L82-L86](https://github.com/appcelerator/titanium_mobile/blob/7aad8f10fe4b46e6eed32c057af1dbf8f2c99624/android/runtime/v8/src/native/ProxyFactory.cpp#L82-L86) Let's purposely make it crash by adding the below "badPointer" line of code below. This will cause the app to segfault and dump a trace in the C/C++ library. This might help us isolate the cause of this issue.
       Local<Object> v8Proxy;
       MaybeLocal<Object> maybeV8Proxy = creator->NewInstance(context, 1, argv);
       if (!maybeV8Proxy.ToLocal(&v8Proxy)) {
       	LOGE(TAG, "Exception thrown while creating V8 proxy.");
       	V8Util::reportException(isolate, tryCatch);
       	int* badPointer = nullptr; *badPointer = 1;  // <- Add this line.
       	return Local<Object>();
       }
       
    We don't currently support debugging the C/C++ side of the SDK even on our end... yet. It's something I want to look into in the future. So, we'll have to do this the hard way at the moment.

JSON Source