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

FHIR Core Enhancements #3587

Merged
merged 47 commits into from
Dec 11, 2024
Merged

FHIR Core Enhancements #3587

merged 47 commits into from
Dec 11, 2024

Conversation

ndegwamartin
Copy link
Contributor

@ndegwamartin ndegwamartin commented Nov 1, 2024

IMPORTANT: Where possible all PRs must be linked to a Github issue

Related ticket: #3486

Engineer Checklist

  • I have written Unit tests for any new feature(s) and edge cases for bug fixes
  • I have added any strings visible on UI components to the strings.xml file
  • I have updated the CHANGELOG.md file for any notable changes to the codebase
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the project's style guide
  • I have built and run the FHIRCore app to verify my change fixes the issue and/or does not break the app
  • I have checked that this PR does NOT introduce breaking changes that require an update to Content and/or Configs? If it does add a sample here or a link to exactly what changes need to be made to the content.

Code Reviewer Checklist

  • I have verified Unit tests have been written for any new feature(s) and edge cases
  • I have verified any strings visible on UI components are in the strings.xml file
  • I have verifed the CHANGELOG.md file has any notable changes to the codebase
  • I have verified the solution has been implemented in a configurable and generic way for reuseable components
  • I have built and run the FHIRCore app to verify the change fixes the issue and/or does not break the app

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

Attention: Patch coverage is 32.25806% with 105 lines in your changes missing coverage. Please review.

Project coverage is 26.8%. Comparing base (aef0fdc) to head (73cb387).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...martregister/fhircore/engine/sync/AppSyncWorker.kt 8.7% 52 Missing ⚠️
...rtregister/fhircore/engine/sync/SyncBroadcaster.kt 0.0% 11 Missing ⚠️
...egister/fhircore/quest/ui/main/AppMainViewModel.kt 0.0% 11 Missing ⚠️
...core/engine/configuration/ConfigurationRegistry.kt 57.8% 8 Missing ⚠️
...register/fhircore/quest/ui/login/LoginViewModel.kt 37.5% 4 Missing and 1 partial ⚠️
...ter/fhircore/engine/sync/OpenSrpDownloadManager.kt 0.0% 4 Missing ⚠️
...gister/fhircore/engine/sync/SyncListenerManager.kt 0.0% 4 Missing ⚠️
...hircore/engine/util/extension/ResourceExtension.kt 89.6% 0 Missing and 3 partials ⚠️
...ter/fhircore/quest/ui/main/components/AppDrawer.kt 0.0% 3 Missing ⚠️
...smartregister/fhircore/engine/util/ParallelUtil.kt 66.6% 0 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main   #3587     +/-   ##
=========================================
- Coverage     28.1%   26.8%   -1.4%     
- Complexity     798     801      +3     
=========================================
  Files          282     284      +2     
  Lines        14495   15053    +558     
  Branches      2584    2667     +83     
=========================================
- Hits          4084    4036     -48     
- Misses        9872   10500    +628     
+ Partials       539     517     -22     
Flag Coverage Δ
engine 62.5% <36.1%> (-1.7%) ⬇️
geowidget 16.0% <ø> (ø)
quest 5.1% <12.0%> (-0.8%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...tregister/fhircore/engine/sync/CustomSyncWorker.kt 58.0% <100.0%> (ø)
...gister/fhircore/engine/util/SharedPreferenceKey.kt 100.0% <100.0%> (ø)
...smartregister/fhircore/engine/util/ParallelUtil.kt 66.6% <66.6%> (-8.4%) ⬇️
...smartregister/fhircore/quest/QuestConfigService.kt 0.0% <0.0%> (ø)
...hircore/quest/ui/appsetting/AppSettingViewModel.kt 2.2% <0.0%> (-0.1%) ⬇️
...fhircore/quest/ui/usersetting/UserSettingScreen.kt 0.0% <0.0%> (-2.3%) ⬇️
...hircore/engine/util/extension/ResourceExtension.kt 67.5% <89.6%> (-0.4%) ⬇️
...ter/fhircore/quest/ui/main/components/AppDrawer.kt 0.0% <0.0%> (ø)
...ter/fhircore/engine/sync/OpenSrpDownloadManager.kt 30.0% <0.0%> (-12.9%) ⬇️
...gister/fhircore/engine/sync/SyncListenerManager.kt 80.7% <0.0%> (-14.7%) ⬇️
... and 5 more

... and 28 files with indirect coverage changes

@dubdabasoduba
Copy link
Member

Tests run on Samsung A25 (128+6GB)
Release App(Madagascar)

  • Login(follow up) - 0:00:26.23
  • Load SP Register(298SPs - Filter, clear app from memory, then login afresh) - 0:02:31.16
  • Search a SP - 0:05:32.22
  • Load a Service Point profile - 0:00:01.38
  • Loading a SP check form - 0:00:00.99
  • Submit a SP check form(save) - 0:00:01.50
  • Loading a Consult beneficiaries form - 0:00:01.08
  • Submit a Consult beneficiaries form(save) - 0:00:01.48
  • Loading a Update GPS form - 0:00:00.98
  • Submit a Update GPS form(save) - 0:00:00.93
  • Loading Past Visit page - 0:00:00.9

Performance app

  • Login(follow up) - 0:00:12.15
  • Load SP Register(290SPs - Filter, clear app from memory, then login afresh) - 0:02:02.90
  • Search a SP - 0:00:27.85(first result) - 0:03:10.55(complete search)
  • Load a Service Point profile - 0:00:01.35
  • Loading a SP check form - 0:00:01.46
  • Submit a SP check form(save) - 0:00:01.31
  • Loading a Consult beneficiaries form - 0:00:01.80
  • Submit a Consult beneficiaries form(save) - 0:00:01.43
  • Loading a Update GPS form - 0:00:01.56
  • Submit a Update GPS form(save) - 0:00:01.56
  • Loading Past Visit page - 0:00:01.04

@dubdabasoduba
Copy link
Member

@Mstjamush Thanks for the feedback

*
* @param T the type of elements in the iterable
*/
suspend fun <T> Iterable<T>.forEachAsync(action: suspend (T) -> Unit): Unit = coroutineScope {
forEach { async { action(it) } }
forEach { launch(Dispatchers.Default) { action(it) } }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Launching coroutines in a for each would negatively impact the app's performance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is because of the overhead incurred when launching a coroutine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose it depends on the intended usage for the async for each. e.g. if we are going to make a network request for each item in the foreach then the overhead will be negligible compared?

@ndegwamartin ndegwamartin marked this pull request as ready for review December 5, 2024 14:44
@dubdabasoduba
Copy link
Member

@ndegwamartin I seem to be getting this error everytime I run the app

FATAL EXCEPTION: main (Ask Gemini)
                                                                                                    Process: org.smartregister.opensrp.eusmMg, PID: 9337
                                                                                                    android.app.InvalidForegroundServiceTypeException: Starting FGS with type none callerApp=ProcessRecord{4ad06d9 9337:org.smartregister.opensrp.eusmMg/u0a190} targetSDK=34 has been prohibited
                                                                                                    	at android.app.InvalidForegroundServiceTypeException$1.createFromParcel(InvalidForegroundServiceTypeException.java:53)
                                                                                                    	at android.app.InvalidForegroundServiceTypeException$1.createFromParcel(InvalidForegroundServiceTypeException.java:49)
                                                                                                    	at android.os.Parcel.readParcelableInternal(Parcel.java:4870)
                                                                                                    	at android.os.Parcel.readParcelable(Parcel.java:4852)
                                                                                                    	at android.os.Parcel.createExceptionOrNull(Parcel.java:3052)
                                                                                                    	at android.os.Parcel.createException(Parcel.java:3041)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3024)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:2966)
                                                                                                    	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761)
                                                                                                    	at android.app.Service.startForeground(Service.java:862)
                                                                                                    	at androidx.work.impl.foreground.SystemForegroundService$Api31Impl.startForeground(SystemForegroundService.java:193)
                                                                                                    	at androidx.work.impl.foreground.SystemForegroundService$1.run(SystemForegroundService.java:129)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

@ndegwamartin
Copy link
Contributor Author

@ndegwamartin I seem to be getting this error everytime I run the app

FATAL EXCEPTION: main (Ask Gemini)
                                                                                                    Process: org.smartregister.opensrp.eusmMg, PID: 9337
                                                                                                    android.app.InvalidForegroundServiceTypeException: Starting FGS with type none callerApp=ProcessRecord{4ad06d9 9337:org.smartregister.opensrp.eusmMg/u0a190} targetSDK=34 has been prohibited
                                                                                                    	at android.app.InvalidForegroundServiceTypeException$1.createFromParcel(InvalidForegroundServiceTypeException.java:53)
                                                                                                    	at android.app.InvalidForegroundServiceTypeException$1.createFromParcel(InvalidForegroundServiceTypeException.java:49)
                                                                                                    	at android.os.Parcel.readParcelableInternal(Parcel.java:4870)
                                                                                                    	at android.os.Parcel.readParcelable(Parcel.java:4852)
                                                                                                    	at android.os.Parcel.createExceptionOrNull(Parcel.java:3052)
                                                                                                    	at android.os.Parcel.createException(Parcel.java:3041)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3024)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:2966)
                                                                                                    	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761)
                                                                                                    	at android.app.Service.startForeground(Service.java:862)
                                                                                                    	at androidx.work.impl.foreground.SystemForegroundService$Api31Impl.startForeground(SystemForegroundService.java:193)
                                                                                                    	at androidx.work.impl.foreground.SystemForegroundService$1.run(SystemForegroundService.java:129)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

@dubdabasoduba pushed a potential fix, could you test out again?

@dubdabasoduba
Copy link
Member

@ndegwamartin I am now getting an error.

 FATAL EXCEPTION: main (Ask Gemini)
                                                                                                    Process: org.smartregister.opensrp.eusmMg, PID: 4959
                                                                                                    java.lang.IllegalArgumentException: foregroundServiceType 0x00000001 is not a subset of foregroundServiceType attribute 0x00000000 in service element of manifest file
                                                                                                    	at android.os.Parcel.createExceptionOrNull(Parcel.java:3061)
                                                                                                    	at android.os.Parcel.createException(Parcel.java:3041)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3024)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:2966)
                                                                                                    	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761)
                                                                                                    	at android.app.Service.startForeground(Service.java:862)
                                                                                                    	at androidx.work.impl.foreground.SystemForegroundService$Api31Impl.startForeground(SystemForegroundService.java:193)
                                                                                                    	at androidx.work.impl.foreground.SystemForegroundService$1.run(SystemForegroundService.java:129)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                                                                                                    Caused by: android.os.RemoteException: Remote stack trace:

@dubdabasoduba
Copy link
Member

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Dec 9, 2024

Getting ANR on this latest branch @ndegwamartin

Screenshot 2024-12-09 at 1 14 43 PM

@dubdabasoduba
Copy link
Member

@ndegwamartin I am now getting a new error when downloading the items linked to a list

 Work [ id=dd3c4957-a367-4cdd-8226-b5b50b865ccf, tags={ org.smartregister.fhircore.quest.ui.login.ConfigDownloadWorker } ] failed because it threw an exception/error (Ask Gemini)
                                                                                                    java.util.concurrent.ExecutionException: java.io.InterruptedIOException: timeout
                                                                                                    	at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:515)
                                                                                                    	at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:474)
                                                                                                    	at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:316)
                                                                                                    	at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    Caused by: java.io.InterruptedIOException: timeout
                                                                                                    	at okhttp3.internal.connection.RealCall.timeoutExit(RealCall.kt:398)
                                                                                                    	at okhttp3.internal.connection.RealCall.callDone(RealCall.kt:360)
                                                                                                    	at okhttp3.internal.connection.RealCall.noMoreExchanges$okhttp(RealCall.kt:325)
                                                                                                    	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:209)
                                                                                                    	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
                                                                                                    	at java.lang.Thread.run(Thread.java:1012) 
                                                                                                    	Suppressed: java.io.InterruptedIOException: timeout
                                                                                                    		... 8 more
                                                                                                    	Caused by: java.io.IOException: Canceled

@dubdabasoduba
Copy link
Member

 okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL (Ask Gemini)
                                                                                                    	at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.kt:148)
                                                                                                    	at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.kt:97)
                                                                                                    	at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:110)
                                                                                                    	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:93)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at io.sentry.okhttp.SentryOkHttpInterceptor.intercept(SentryOkHttpInterceptor.kt:110)
                                                                                                    	at io.sentry.android.okhttp.SentryOkHttpInterceptor.intercept(Unknown Source:7)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at org.smartregister.fhircore.engine.di.NetworkModule.provideOkHttpClient$lambda$3(NetworkModule.kt:130)
                                                                                                    	at org.smartregister.fhircore.engine.di.NetworkModule.$r8$lambda$mZPdIz9yVxGN-hif8gZFKBwXogM(Unknown Source:0)
                                                                                                    	at org.smartregister.fhircore.engine.di.NetworkModule$$ExternalSyntheticLambda1.intercept(D8$$SyntheticClass:0)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at org.smartregister.fhircore.engine.di.NetworkModule.provideOkHttpClient$lambda$1(NetworkModule.kt:104)
                                                                                                    	at org.smartregister.fhircore.engine.di.NetworkModule.$r8$lambda$vZYSyZyKyFZ9mcwJ3hiivLs6Y_g(Unknown Source:0)
                                                                                                    	at org.smartregister.fhircore.engine.di.NetworkModule$$ExternalSyntheticLambda0.intercept(D8$$SyntheticClass:0)
                                                                                                    	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
                                                                                                    	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
                                                                                                    	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)

Copy link
Contributor

@f-odhiambo f-odhiambo left a comment

Choose a reason for hiding this comment

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

LGTM

@ndegwamartin ndegwamartin merged commit 1c56506 into main Dec 11, 2024
4 of 5 checks passed
@ndegwamartin ndegwamartin deleted the enhancements branch December 11, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants