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

RNMT-4515 Fixes an issue with recent devices running Android 11 #1

Merged
merged 5 commits into from Nov 26, 2020

Conversation

luissilvaos
Copy link

Description

This PR introduces the changes that fixes an issue with the recent devices running Android 11, by introducing a complex type for the representation of the SQL Handle and the SQLite operation result, instead of mixing both values into a long value.

Context

Fixes https://outsystemsrd.atlassian.net/browse/RNMT-4515

The previous approach was using a simple type to return the SQL handle.
The returned handle value was a mix between the result value of SQLite
operation and the SQL handle, where negative number indicates an error,
causing the issues in the recent devices running Android 11,
where the memory addresses of the handle were valid but they were also
negative numbers when converted to the `long long` type.

With this new complex type for the SQL Handle, we are now able to return
both the result of the SQLite operation and the SQL handle.

References https://outsystemsrd.atlassian.net/browse/RNMT-4515
# For future consideration (needs testing):
#APP_ABI += mips mips64

APP_PLATFORM := android-23

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we gaining anything from this bump ? Also, reading the docs https://developer.android.com/ndk/guides/application_mk#app_platform it states that this should match the minSdkVersion , 23 is Android 6 but we support Android 5.1 , right ? If there's no gain from this being set as we, I don't see a reason for this to be break change by bumping this to 23

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we only support Android 6+ in MABS 7. Both 5 and 5.1 were dropped.

Copy link

@Chuckytuh Chuckytuh Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we're just introducing a breaking change without actually needing it on this package, right? What if tomorrow we need to fix something here that's needs to be applied also on MABS 5, we'll have to deal with release branches and whatnot for no reason

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point, but to be honest, I don't see it as a problem. Here are my thoughts regarding this topic:

  • We already have breaking changes in the cordova-sqlite-storage plugin for MABS 7.
  • The current version used by MABS 6 has been a stable version.
  • If we somehow have to deal with some fixes in the lib versions that support cordova-sqlite-storage for MABS 6 we can just create a branch for that.
  • Also, the changes introduced in this PR aren't a simple fix that we can simply port to MABS 6. IMHO, they should only be applied to the version that will be released with MABS 7, due to the eventual impacts that they may cause.

Comment on lines +16 to +17
#define HANDLE_FROM_VP(p) (( (unsigned char *)(p) - (unsigned char *)NULL ) )
#define HANDLE_TO_VP(h) (void *)( (unsigned char *)NULL + (ptrdiff_t)((h)) )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this no longer is required. Or is there something to it ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the BASE_OFFSET and left it there to be an helper for the conversions pointer -> long and long -> pointer, and to minimize the changes in the code as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's no longer required because it's no longer +number = pointer -number = error.

Copy link

@EiyuuZack EiyuuZack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. What a headache this must have been considering upstream has not be updated in years...

return this.handle;
}

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at the end

return _res;

jclass class = (*env)->FindClass(env,"io/liteglue/SQLiteResponse");
jmethodID constructor = (*env)->GetMethodID(env, class, "<init>", "(IJ)V");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"(IJ)V"? What is this? Is it really a static thing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the convention for the method signature. Check this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will never again complain about JavaScript 😂

@@ -143,19 +150,26 @@ Java_io_liteglue_SQLiteNative_sqlc_1db_1open__Ljava_lang_String_2I(JNIEnv *env,
if ( NULL != filename ) {
(*env)->ReleaseStringUTFChars(env, filename, _strchars_filename);
}
return _res;

jclass class = (*env)->FindClass(env,"io/liteglue/SQLiteResponse");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can refactor this code to avoid duplication?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that will be a good improvement.

@Chuckytuh
Copy link

Just adding context that this relates with storesafe/cordova-sqlite-storage#954

brodybits added a commit to brodybits/android-sqlite-ndk-native-driver that referenced this pull request Mar 22, 2021
Merge commit 'a69fa8fea29d77b781b1250554932174328ff337' of https://github.com/OutSystems/Android-sqlite-native-driver into main

include some updates from this PR on the OutSystems fork:

- OutSystems/Android-sqlite-native-driver#1
gauthierm added a commit to silverorange/Android-sqlite-ext-native-driver that referenced this pull request Sep 8, 2021
This contains changes to the native C code.
gauthierm added a commit to silverorange/Android-sqlite-ext-native-driver that referenced this pull request Sep 8, 2021
…ned structs

This was done manually in OutSystems/Android-sqlite-native-driver#1 and is done with Gluegen in this commit.
gauthierm added a commit to silverorange/react-native-sqlite-storage that referenced this pull request Sep 8, 2021
ArGeoph pushed a commit to ArGeoph/react-native-sqlite-storage that referenced this pull request Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants