-
Notifications
You must be signed in to change notification settings - Fork 42
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
Case 1340464 - remove GC allocation every frame on Android #101
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels fragile, for this code to work correctly, m_ReceivedNotificationList has to be empty, when the switch occurs. If it's not empty then out of order processing of notifications is possible. Only by looking at the whole file I understand that m_ReceivedNotificationList is empty when this switch occurs, but still if in the future someone will mess with m_ReceivedNotificationList, it will be easy to miss this place
Consider adding a safeguard
if (m_ReceivedNotificationList.Count != 0)
throw new Exception(..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not empty, it means there are leftover notifications from last processing which shouldn't happen. Actually, this code still has a bug where this could happen (in case of exception), but that's addressed in different PR. When such leftovers happen, you get callbacks called again for the same notification next frame, most likely leading to the same exception again and postponing the same issue to the next frame etc. This change would scramble the ordering, but you'd still get bombarded with callbacks every frame when this happens.
Throwing exception like you propose would prevent callbacks from being called with logging about a bug. IMO, not throwing exception gives a clearer indication of bug (but it doesn't log the exact issue).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"clearer indication of bug" - really? :) it's really not that apparent, especially for a green user. Well, if you're a fan of hidden bugs, so be it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for sure clearer in our test project, reducing chances of us releasing a bug :)