-
-
Notifications
You must be signed in to change notification settings - Fork 408
fix: catch CoreAnimation exceptions in redaction #8537
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
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b87611f
fix: catch CoreAnimation exceptions in redaction
philprime 4f2f1e2
docs: add changelog for #8537
philprime 1eb0d30
Merge branch 'main' into philprime/catch-animation-exceptions-7810
philprime 301f70e
Merge branch 'main' into philprime/catch-animation-exceptions-7810
philprime a4336e6
Merge remote-tracking branch 'origin/main' into philprime/catch-animaβ¦
philprime 3e7d9a2
fix: guard presentation layer and overmask on layer crash
philprime 90ad160
Merge remote-tracking branch 'origin/main' into philprime/catch-animaβ¦
philprime 04589d1
Merge remote-tracking branch 'origin/main' into philprime/catch-animaβ¦
philprime abc189e
fix: Log caught Objective-C exceptions
philprime 394c8b2
docs: Link replay exception troubleshooting
philprime d4c3607
fix: Narrow replay exception handling
philprime db6e799
docs: Link presentation fallback guidance
philprime 58b66b1
fix: Preserve replay unmask fallback
philprime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #import "SentryObjCExceptionHelper.h" | ||
| #import "SentryLogC.h" | ||
|
|
||
| @implementation SentryObjCExceptionHelper | ||
|
|
||
| + (BOOL)tryBlock:(NS_NOESCAPE void (^)(void))block | ||
| catchingExceptionWithName:(NSExceptionName)name | ||
| reasonPrefix:(NSString *)reasonPrefix | ||
| { | ||
| @try { | ||
| block(); | ||
| return YES; | ||
| } @catch (NSException *exception) { | ||
|
philprime marked this conversation as resolved.
|
||
| if (![exception.name isEqualToString:name] || ![exception.reason hasPrefix:reasonPrefix]) { | ||
|
philprime marked this conversation as resolved.
|
||
| @throw; | ||
| } | ||
|
|
||
| SENTRY_LOG_WARN(@"Caught Objective-C exception %@: %@", exception.name, exception.reason); | ||
| return NO; | ||
| } | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #import <Foundation/Foundation.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /// Helper to run a block inside an Objective-C `@try`/`@catch`. | ||
| /// | ||
| /// Swift cannot catch Objective-C exceptions. Some system frameworks (notably Core Animation) | ||
| /// raise `NSException`s from code paths the SDK has to touch β for example resolving a layer's | ||
| /// presentation layer while a malformed `CABasicAnimation` is running raises | ||
| /// `-[NSConcreteValue doubleValue]: unrecognized selector`. When such an exception unwinds through | ||
| /// Swift frames it force-kills the host app. This helper lets Swift callers run the risky access | ||
| /// inside an Objective-C exception handler so they can degrade gracefully instead of crashing. | ||
| /// | ||
| /// See https://github.com/getsentry/sentry-cocoa/issues/7810 for context. | ||
| @interface SentryObjCExceptionHelper : NSObject | ||
|
|
||
| /// Executes `block` inside an Objective-C `@try`/`@catch`. | ||
| /// | ||
| /// - Parameter block: The block to execute. It is run synchronously before this method returns. | ||
| /// - Parameter name: The name of the exception to catch. | ||
| /// - Parameter reasonPrefix: The prefix of the exception reason to catch. | ||
| /// - Returns: `YES` if `block` completed without raising an `NSException`, `NO` if a matching | ||
| /// exception was caught and swallowed. Non-matching exceptions are rethrown. | ||
| + (BOOL)tryBlock:(NS_NOESCAPE void (^)(void))block | ||
| catchingExceptionWithName:(NSExceptionName)name | ||
| reasonPrefix:(NSString *)reasonPrefix | ||
| NS_SWIFT_NAME(tryBlock(_:catchingExceptionWithName:reasonPrefix:)); | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.