-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[hold for payment 25 august] Onyx changes break Exisiting App architecture. #4500
Comments
Triggered auto assignment to @arielgreen ( |
My point here is What is an issue with triggering a render even if data is not changed? If user merge( If we want to block a render then this should be handled in the component level The issue seems to be due to the Object comparison here. https://github.com/Expensify/react-native-onyx/blob/d7553b95e982ab78f6bb2064f6b0549f0ace94c2/lib/Onyx.js#L479 Even if we want to drop a render if data is not changed and then we should only do Instance matching (ob1 === ob2). |
We're not doing it to skip a render, but to skip re-writing the same data to storage To let components re-render and still skip a write to storage we can move this to the top of the method // Optimistically inform subscribers on the next tick
Promise.resolve().then(() => keyChanged(key, val)); But do we want to raise a "change" event, when storage didn't really change ? It doesn't seem valid to use something like
Instead of relying on storage to raise a "change" event, even though it didn't really change, we can capture a loading state
It's cleaner and easier to reason about instead of having to explain why the component uses |
After analysing
1. AdditionalDetailsStep (walletAdditionalDetails)Has App/src/pages/EnablePayments/AdditionalDetailsStep.js Lines 39 to 43 in 50828ab
2. EnablePaymentsPage (userWallet)Discussed in the current issue - does not track loading state but relies on 3. OnfidoStep (walletOnfidoData)Has App/src/pages/EnablePayments/OnfidoStep.js Lines 42 to 47 in 50828ab
4. TermsStep (walletTerms)Has App/src/pages/EnablePayments/TermsStep.js Lines 31 to 35 in 50828ab
5. Expensify (updateAvailable)It's possible to have a problem here, Lines 53 to 63 in 50828ab
I don't know why we ignore the storage value of App/src/components/OnyxProvider.js Line 15 in 50828ab
6. LHN loading stateLines 19 to 24 in 50828ab
Always treated like Lines 54 to 61 in 50828ab
BTW it's already initalised with App/src/components/OnyxProvider.js Line 24 in 50828ab
|
Nice writeup. So what should be done for these cases?
I don't tightly couple the usages of
|
Great conversation around this and it sounds like it might be worth exploring a deprecation of Is there some interim solution we can go with for now? e.g. could we always notify any subscribers that have |
@marcaaron yeah we can just send the notification without updating the Onyx Store.
It solves the issue without breaking new changes of Onyx. |
I'm not sure 1 will work - bc we need to set the value before calling
So something like this... ? const shouldCacheNewValue = !cache.hasCacheForKey(key) || !_.isEqual(val, cache.getValue(key));
if (shouldCacheNewValue)
cache.set(key, val);
}
// Optimistically inform subscribers on the next tick
Promise.resolve().then(() => keyChanged(key, val, shouldCacheNewValue)); Then handle the update to subscribers in |
Oh Yeah. for the other cases, this is necessary. Sorry slipped from my mind. Then, if shouldCacheNewValue is false, only trigger a notification only for |
@marcaaron, since you're eng triaging this, can you go ahead and throw |
@arielgreen Seems like a regression though. We usually have whoever caused the regression address it and not create separate tickets - so I'm not sure what to do in this case. |
Everything that's needed to achieve the previous behaviour is to move this line to the start of the call Promise.resolve().then(() => keyChanged(key, val)); It's just a matter of deciding if it's correct to call Reverting to the previous behaviour would also degrade performance as it will cause more re-renders, but at least we'll skip writing to storage |
I don't see a reason for this |
for keys whose value is different from the cache. |
To clarify the suggestion is to only run
So I think this just means things that are flagged with |
Also, I think if the component is optimized a render should not be big deal. We are already reusing the Onyx subscriptions so resubscribing to WitOnyx should be fast. |
The problem is not caching the value but writing it to storage - we should not skip caching but the hard write to storage |
I don't see proposals that addresses this:
And I don't think it's possible to address it in
We should either always skip notifying when storage didn't change or always notify. There's no way to do it just for the |
I think the optimisation updates just revealed a hidden problem - other components with loading state would capture it in Onyx |
Alright, I'd still recommend that we fix this to restore the behavior that has changed. Less concerned with how it is resolved as long as the solution is simple. |
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open
|
Thanks for pointing out @marcaaron.
This makes sense. I see that you are reverting both PRs. I will wait to see if new changes are pushed from Expensify/react-native-onyx#92. |
Gonna issue payment on 25 August to account for regression 👍🏽 |
@laurenreidexpensify I have a doubt about the task. The changes which I did are reverted and the original change which caused this issue is also reverted. So this issue does not exist as both of the PRs are taken down. Secondly, I am not sure about Marc's comment about that PR linked to this issue caused that side effect as the things he has mentioned are not related to PR's changes. Evey if they are I am not sure how. so in short, you can say that this is not valid anymore. Now, I am not sure how to handle such case. |
@laurenreidexpensify, @parasharrajat @marcaaron's investigation is correct. The problem is with cache and the LRU update: #4509
The "old" cache cleaning logic took "default keys" into consideration and never cleared them from cache We could 1) restrict cache cleanup to clear only the "safe eviction" keys from cache - this aids performance as well or 2) add a check to skip clearing default keys (like we used to do before LRU cache) One of the optimizations of |
I'll be happy to open a PR to address the regressions, as it's caused by a PR of mine Both approaches are pretty much handled the same way - we give "Cache" a list of keys that should not be cleared |
Okay thanks for the summary - let's wait for Marc to get online later and take a look here to give us a forward steer 👍🏽 |
Thanks, @kidroca, I agree with the point that changes done in the linked PR are not the cause of the issue. It's just the side case was not handled. Anyways, I am sure that we are going to keep the LRU cache so a fix to the occurred issue #4500 (comment) and #4509 and changes in Expensify/react-native-onyx#96, all are needed. |
@marcaaron Awaiting your response in the discussion. Please let us know what is the next thing to do. |
Sorry, I will be tied up with some other duties for a bit. But I don't think there is anything that urgently needs to be done here. I understand @parasharrajat was assigned to this issue. The reverts have resolved the original issue. This should also no longer be a deploy blocking issue and can be closed. I'd suggest we create a new issue to discuss further improvements and just close this one. |
Any update on Upwork @laurenreidexpensify ? |
🚀 Deployed to production by @roryabraham in version: 1.0.88-2 🚀
|
Neither I recieved the job offer nor I got paid for reporting the issue and submitting the PR. Would someone like to clarify what's up with this issue? I am waiting for a clarification from a couple of days now. #4500 (comment) |
cc: @MitchExpensify Out of nowhere. Sorry. |
Hey @parasharrajat ! Sorry for the delay, Lauren is out of office right now. I can jump in :) Hire offer sent, please accept and I will pay for job completion. To confirm, did you identify this issue? It appears so but just making sure |
@MitchExpensify |
Any update @MitchExpensify? Sorry for the confusing comment, I have updated it. |
Paid with bonus! Thanks @parasharrajat |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
cc: @marcaaron @kidroca
ISSUE
There few parts that will stop working due to the recent changes to Onyx. We have to either plan for migration or fix Onyx so that those continue working.
There is a component Enablepayment which uses the following implementation.
App/src/pages/EnablePayments/index.js
Lines 50 to 58 in 50828ab
userWallet:{}
value.Slack thread => https://expensify.slack.com/archives/C01GTK53T8Q/p1628106963153400
Expected Result:
UI should be updated to show the recent state of data.
Actual Result:
Workaround:
None. It breaks the App.
Platform:
Where is this issue occurring?
Version Number: 1.0.82
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
View all open jobs on Upwork
The text was updated successfully, but these errors were encountered: