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

Native set load measured #8242

Merged
merged 5 commits into from
Oct 14, 2024
Merged

Native set load measured #8242

merged 5 commits into from
Oct 14, 2024

Conversation

larkox
Copy link
Contributor

@larkox larkox commented Oct 3, 2024

Summary

The React context may disappear for several reasons while leaving the native context alive. This makes it so the initial mark created by react-native-performance in the native side lives between React context restarts. This may be creating issues about recognizing whether the load metric to have been measured or not, which may lead to wrong measures.

In order to avoid this, we store whether we have measured or not the metric on the native side. This way we make sure this variable stays "alive" until the end of life of the native context.

Ticket Link

Fix https://mattermost.atlassian.net/browse/MM-59857

Release Note

Improve load performance measures

@larkox larkox added the 2: Dev Review Requires review by a core commiter label Oct 3, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes in this package are because of changes in iOS 18.

Copy link
Contributor

@enahum enahum Oct 3, 2024

Choose a reason for hiding this comment

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

There is a better solution for this.. I'll share when I can.

Btw this is cause Xcode 16 not ios 18

Copy link
Contributor

Choose a reason for hiding this comment

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

The better way to fix this issue is by adding this line typealias Expression = SQLite.Expression after the imports in the Storage/Database.swift file, all other changes to the Gekidou library would not be needed.

package.json Outdated
@@ -39,7 +39,7 @@
"@react-navigation/native": "6.1.18",
"@react-navigation/stack": "6.4.1",
"@rneui/base": "4.0.0-rc.8",
"@sentry/react-native": "5.27.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The package upgrade is because errors, probably related to iOS 18.

Copy link
Contributor

Choose a reason for hiding this comment

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

Xcode 16 :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing this needs to ipdate the cocoaSDK version on the xcode project as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure that version v8.36.0 is used in the workspace Package.resolve of the xcode project

image

Copy link
Contributor

@rahimrahman rahimrahman left a comment

Choose a reason for hiding this comment

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

I only have a few questions, nothing that needs to be updated.

let idCol = Expression<String>("id")
let teamIdCol = Expression<String>("team_id")
let typeCol = Expression<String>("type")
let idCol = SQLite.Expression<String>("id")
Copy link
Contributor

@rahimrahman rahimrahman Oct 4, 2024

Choose a reason for hiding this comment

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

Are these changes because of Xcode 16? If they are Since this changes are caused by Xcode 16 unrelated to the problem, would it have been better to handle those in a separate PR beforehand. It would help keep the focus on the main bug fix here.

Updated: since I read previous comment that the problem is due to Xcode 16.

Copy link
Contributor

Choose a reason for hiding this comment

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

I admit, when I saw 23 files changed, I made a note to myself that I need to carve a bit more time to run through this PR.

await TestHelper.tick();
expect(mockApiClient.post).toHaveBeenCalledWith(expectedUrl, expectedRequest);
mockApiClient.post.mockClear();
PerformanceMetricsManager.finishLoad('HOME', serverUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: we expected to not see another call if we only call finishLoad() again, right? Besides that scenario, is there any merit to see if we do another call to performance.mark() and then finishLoad() during the same "session"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean with that. The performance.mark() call we do in the test is to mock what happens in the native side, since unit tests don't deal with native side. Calling again performance.mark(), on top of not giving us extra information, would not reflect what happens on the native side.

Or did I misunderstood your comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

Silly me, I misunderstood. performance.mark() just instantiate a new class with value from markName and will not affect what you're testing here which is finishLoad().

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow-up suggestion, I think there might be a merit to cover the skipLoadMetric() just to make sure that no API calls are being posted.

@rahimrahman
Copy link
Contributor

rahimrahman commented Oct 4, 2024

Since we want to know and confirm the effectiveness of this fix, is there a follow-up ticket or some sort of reminder or a temp chart/grafana measurement that will indicate these changes do solve the problem?

Not a requirement, interested in the process.

@larkox
Copy link
Contributor Author

larkox commented Oct 11, 2024

I created a new PR (#8254) for the XCode16 changes. When that is merged, I will update this one accordingly.

@rahimrahman
Copy link
Contributor

I created a new PR (#8254) for the XCode16 changes. When that is merged, I will update this one accordingly.

Thanks for doing that @larkox -- the changes here feels a lot more to the point, without other things cluttering it.

Still approved. 👍🏽

@larkox
Copy link
Contributor Author

larkox commented Oct 14, 2024

@enahum Friendly reminder on this

Copy link
Contributor

@enahum enahum left a comment

Choose a reason for hiding this comment

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

Lgtm

@larkox larkox added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Oct 14, 2024
@larkox
Copy link
Contributor Author

larkox commented Oct 14, 2024

@yasserfaraazkhan Skipping QA review since there are no functional changes, and I already tested what this should fix.

@larkox larkox merged commit bc8a42b into main Oct 14, 2024
12 checks passed
@larkox larkox deleted the nativeSetLoadMeasured branch October 14, 2024 14:07
@amyblais amyblais added this to the v2.23.0 milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants