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

Prevent concurrent modifications of audit log #5975

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Feb 19, 2024

Fixes this crash.

This makes sure that logEvent and flush are never executed concurrently which could cause problems.

Why is this the best possible solution? Were any other approaches considered?

We should also remove all uses of logEvent and flush on the UI thread, but that's part of ongoing ANR work (#5867).

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

It'll be hard to reproduce the linked crash (or we probably would have caught it ourselves). I think the best thing to test here is general audit log behaviour - I've made some changes here to how events are logged and that could be risky.

Do we need any specific form for testing your changes? If so, please attach one.

Any forms with audit enabled.

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@seadowg seadowg added this to the v2024.1.x milestone Feb 19, 2024
@seadowg seadowg added the high priority Should be looked at before other PRs/issues label Feb 19, 2024
@seadowg seadowg marked this pull request as ready for review February 19, 2024 13:30
@seadowg seadowg requested a review from grzesiek2010 February 19, 2024 13:30
@grzesiek2010 grzesiek2010 merged commit d9f3d44 into getodk:master Feb 20, 2024
6 checks passed
@seadowg seadowg deleted the audit-sync branch February 20, 2024 13:39
@dbemke
Copy link

dbemke commented Feb 21, 2024

In audit logs the "location providers enabled" event is missing after turning it on in the middle of filling a form (not missing in the store version).
The latitude, longitude and accuracy are present in the events after turning on the location permission.

Steps to reproduce:

  1. Location permission is granted to Collect.
  2. Turn off the location permission of the device in settings.
  3. Go to the AuditTestLocationBackground.xml form.
    AuditTestLocationBackground.xml.txt
  4. Choose “cancel” in the dialog asking to enable GPS.
  5. Fill in some questions.
  6. Minimize the app.
  7. Go to device settings.
  8. Turn on the location permission.
  9. Go back to the opened form and fill some questions.
  10. Click “Save as draft” button (end page).

Expected behavior
In audit log after turning on the location permission and going back to the form there should be "location providers enabled" event.

@seadowg
Copy link
Member Author

seadowg commented Feb 21, 2024

Turn off the location permission of the device in settings.

Just to check: is this disabling "Use location" for all apps, or just removing the location permission from Collect?

EDIT: I realise that "location providers enabled" implies the former.

@seadowg
Copy link
Member Author

seadowg commented Feb 21, 2024

@dbemke I'm not able to reproduce on an Android 13 device. Are you seeing this sporadically or only on a specific OS/device?

@dbemke
Copy link

dbemke commented Feb 21, 2024

I think I know what might have happened. It also appeared on Android 13. I just checked Android 14 and it didn't occur.
I mainly tested it on Android 10 when comparing results and I'm able to reproduce it every time. Now I managed to get the event "location provider enabled" but I left the form opened for 5min after enabling the location again. So it seems that in the store version of Collect the event appeared faster. While testing I usually wait 10-20seconds after changing location permission so in that case I got different results (the event present or not). I guess that geometry values that were in audit logs might have been some stored values but really the location wasn't enabled during that 20second gap. Do you think this might be the case? Should I check the difference in time after enabling location and seeing the event in the audit logs or it's an edge case and it can stay as it is?

@dbemke
Copy link

dbemke commented Feb 22, 2024

@seadowg We finished testing audit logs and haven't found any other issues so if you decide that the issue mentioned above is ok, could you remove the "needs testing" label?

@seadowg
Copy link
Member Author

seadowg commented Feb 22, 2024

Should I check the difference in time after enabling location and seeing the event in the audit logs or it's an edge case and it can stay as it is?

Yeah that'd be great! It feels to me like this probably hasn't actually changed between versions and we got unlucky testing it.

@dbemke
Copy link

dbemke commented Feb 27, 2024

Today I tested it again and now the event is present. I'll test the event separately so that the PR can be closed.

@dbemke
Copy link

dbemke commented Feb 27, 2024

Tested with Success!

Verified on Android 10

Verified cases:

  • regression checks in audit logs

@srujner
Copy link

srujner commented Feb 27, 2024

Tested with Success!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behavior verified high priority Should be looked at before other PRs/issues
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

4 participants