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

flushEvents CPU drain #231

Closed
cvb941 opened this issue Mar 3, 2025 · 6 comments · Fixed by #232
Closed

flushEvents CPU drain #231

cvb941 opened this issue Mar 3, 2025 · 6 comments · Fixed by #232
Labels
bug Something isn't working

Comments

@cvb941
Copy link

cvb941 commented Mar 3, 2025

Version

3.11.3

Steps to Reproduce

Run on emulator, Initialize the SDK.

Expected Result

Minimal CPU usage

Actual Result

Function flushEvents is called in a loop forever. CPU usage gets high and triggers a lot of GCs.

Image Image
@cvb941 cvb941 added the bug Something isn't working label Mar 3, 2025
@cvb941
Copy link
Author

cvb941 commented Mar 3, 2025

The problem is here:

val event = config.serializer.deserialize<PostHogEvent?>(theInputStream.reader().buffered())

listFiles contains only a replay-queue file, which fails to get deserialized into a PostHogEvent (result is null) which causes the later events.isNotEmpty() if statement to not pass thus never deleting the file in listFiles

@marandaneto
Copy link
Member

Hello @cvb941 thanks for the report.
The event should be serializable though, very strange that it does not, can you send me a copy of the file in the disk so I can try this out as well?

@cvb941
Copy link
Author

cvb941 commented Mar 3, 2025

I checked the file, and it is empty (0 bytes)

@marandaneto
Copy link
Member

I checked the file, and it is empty (0 bytes)

can you reproduce to actually write this file again as empty 0 bytes? if the bug is in the serialization, this should be addressed first.

@cvb941
Copy link
Author

cvb941 commented Mar 3, 2025

I have no idea how that happened. I just turned on my app in the emulator and noticed the cpu usage. After I deleted the empty file it didn't come back and the issue is not there.

@marandaneto
Copy link
Member

I have no idea how that happened. I just turned on my app in the emulator and noticed the cpu usage. After I deleted the empty file it didn't come back and the issue is not there.

I tried to reproduce this issue and it does not happen at all.
#232 should prevent that at least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants