Skip to content

On iOS use Dart API instead of memcpy #333

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

Merged
merged 3 commits into from
Nov 2, 2021

Conversation

greenrobot-team
Copy link
Member

@greenrobot-team greenrobot-team commented Nov 2, 2021

Workaround for #313

If lookup of native memcpy function fails use a Dart implementation instead.
Except in case of ReaderWithCBuffer where a somewhat faster fallback implementation already exists (in case its shared buffer is too small it creates a new buffer and returns a view of it).

To avoid the performance penalty on real devices might detect the iOS simulator. But this seems only possible using a Flutter plugin (based on an Apple flag available at compile time, e.g. see the Flutter device_info_plus plugin).

/// so use Dart API to copy data via asTypedList (which is much slower but works).
///
/// https://github.com/objectbox/objectbox-dart/issues/313
final isMemcpyNotAvailable = Platform.isIOS;
Copy link
Member

Choose a reason for hiding this comment

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

can we instead catch the error of _stdlib.lookupFunction() below? Would have a couple of advantages?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeap, makes more sense, changed!

Copy link
Member Author

@greenrobot-team greenrobot-team Nov 2, 2021

Choose a reason for hiding this comment

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

Verified to work on iOS 15 simulator using example app.

@greenrobot-team greenrobot-team force-pushed the gh-313-memcpy-ios-workaround branch from e5a442c to 658e837 Compare November 2, 2021 13:32
@greenrobot-team greenrobot-team added this to the 1.2 milestone Nov 2, 2021
@greenrobot-team greenrobot-team merged commit b663647 into main Nov 2, 2021
@greenrobot-team greenrobot-team deleted the gh-313-memcpy-ios-workaround branch November 2, 2021 14:31
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

Successfully merging this pull request may close these issues.

2 participants