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

RUMM-346 Fix "device out of memory" crash #64

Merged

Conversation

ncreated
Copy link
Member

@ncreated ncreated commented Apr 2, 2020

What and why?

🚚 This PR provides a fix for crash reported in #58 where NSFileHandleOperationException was thrown on devices with high memory and disk pressure when writing the log to file.

How?

The exception was thrown when calling write(_ data:) method on FileHandle. This was expected behaviour described by Apple:

This method raises an exception if (...) no free space is left on the file system, or if any other writing error occurs.

Unfortunately Apple doesn't provide throwable variant of fileHandle.write(_:) so we have to catch this error from Objective-C code (until better API is provided in iPhone SDK).

This PR introduces ObjcExceptionHandler which catches NSException and rethrows it as Swift.Error.

Most effort in this PR focuses on introducing separate Objective-C module that we can interoperate with from Swift code and making this module compatible with Carthage, Cocoa Pods and SPM.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference

@ncreated ncreated force-pushed the ncreated/RUMM-346-fix-crash-on-device-out-of-memory branch 3 times, most recently from 6ccda27 to d90ce51 Compare April 2, 2020 16:51
@ncreated ncreated changed the base branch from master to ncreated/RUMM-346-add-cocoapods-test April 2, 2020 16:53
@ncreated ncreated self-assigned this Apr 2, 2020
@ncreated ncreated requested a review from buranmert April 2, 2020 17:41
@ncreated ncreated marked this pull request as ready for review April 2, 2020 17:41
@ncreated ncreated requested a review from a team as a code owner April 2, 2020 17:41
@ncreated ncreated force-pushed the ncreated/RUMM-346-fix-crash-on-device-out-of-memory branch from af6b6e1 to d0ec66e Compare April 6, 2020 10:42
@ncreated ncreated requested a review from a team as a code owner April 6, 2020 10:42
@ncreated ncreated changed the base branch from ncreated/RUMM-346-add-cocoapods-test to ncreated/RUMM-346-unify-dependency-manager-tests April 6, 2020 10:43
@ncreated ncreated force-pushed the ncreated/RUMM-346-fix-crash-on-device-out-of-memory branch from d0ec66e to e35651b Compare April 6, 2020 11:04
ncreated and others added 4 commits April 6, 2020 17:32
DDPrivate module is created to use ObjC from Swift
It is not intended for public use
We used private.modulemap to hide it from public
@ncreated ncreated force-pushed the ncreated/RUMM-346-fix-crash-on-device-out-of-memory branch from e175a16 to cc00074 Compare April 6, 2020 15:32
@ncreated ncreated changed the base branch from ncreated/RUMM-346-unify-dependency-manager-tests to master April 6, 2020 17:13
@ncreated ncreated merged commit e82d85f into master Apr 6, 2020
@ncreated ncreated deleted the ncreated/RUMM-346-fix-crash-on-device-out-of-memory branch April 6, 2020 17:14
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