Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28252] Android: Modules built before 9.3.0 will return empty string instead of null

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-12-03T01:09:34.000+0000
Affected Version/sRelease 9.3.0
Fix Version/sRelease 9.3.0
ComponentsAndroid
Labelsandroid, build, module, regression, v8
ReporterHans Knöchel
AssigneeGary Mathews
Created2020-11-22T22:00:16.000+0000
Updated2020-12-03T01:09:37.000+0000

Description

Noticed during the SDK 9.3.0 migration: If you call a module getter and the value is null, thee app now crashes, because a Symbol type is returned instead of a bare null value. This works fine on iOS and used to work fine on Android as well (comparing to 9.2.2.GA). It's easy to replicate: 1. Create a native module and add the following code:
@Kroll.getProperty
public String fcmToken()
{
	return null;
}
2. Add the module to your tiapp.xml with an 9.3.0 SDK included and call the getter:
console.warn(require('ti.test').fcmToken));
3. Notice the error 4. Change the SDK version back to 9.2.2.GA and run the same app again 5. Notice that it's behaving correctly and returning null. I guess it's a regression from some kind of V8 change (see the full 9.2.2 <-- master diff [here](https://github.com/appcelerator/titanium_mobile/compare/9_2_X...9_3_X)). Also see the ti.test module for quick reproduction attached to this ticket. *EDIT*: Found a possible regression candidate [this commit](https://github.com/appcelerator/titanium_mobile/commit/33964f2e8a2d8afa6549e9e99d66612b907b7bff#diff-d5344920be4f1fff291a2472f2046fed4f37659c8de7227cb483aeb4cc167484R220) (as part of TIMOB-27787).

Attachments

FileDateSize
ti.java.1.0.0.zip2020-11-24T17:58:02.000+0000126360
ti.test-android-1.0.0.zip2020-11-22T21:59:52.000+0000115241

Comments

  1. Joshua Quick 2020-11-23

    I'm not seeing a crash. However, it is returning an empty string when it should be returning null. That is definitely a regression. And it's only happening with older modules running on 9.3.0 like you said. It doesn't happen with 9.3.0 built modules.
  2. Joshua Quick 2020-11-23

    Reverting the V8 library below restores the old behavior. https://github.com/appcelerator/titanium_mobile/pull/12186 It's happening because the inlined V8 constant values have changed between versions causing V8 to index the wrong type (ie: string instead of void, boolean instead of void, etc.). We'll either revert the V8 library or patch the new V8.
  3. Hans Knöchel 2020-11-24

    It does not return a string for us but a Symbol type, causing the crash once we access it, e.g. in a log or comparison.
  4. Gary Mathews 2020-11-24

    master: https://github.com/appcelerator/titanium_mobile/pull/12293
  5. Lokesh Choudhary 2020-11-24

    FR Passed. null is returned as expected. SDK: 9.3.0.v20201124093449
  6. Joshua Quick 2020-11-25

    The following PR adds unit tests for verifying module backward compatibility on Android and iOS. PR (master): https://github.com/appcelerator/titanium_mobile/pull/12311

JSON Source