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

Android: Add Log Configuration to UI #7252

Merged
merged 1 commit into from Aug 2, 2020
Merged

Conversation

Ebola16
Copy link
Member

@Ebola16 Ebola16 commented Jul 12, 2018

@mahdihijazi
Copy link
Contributor

Please check my comment on #7121
I think it will impact this one.

@Ebola16
Copy link
Member Author

Ebola16 commented Feb 21, 2019

Addressed @mahdihijazi 's concerns and updated the PR to include #7318. Lint has been giving me a lot of problems though. Any idea how to fix the lint issues? I ran ctrl+alt+L in android studio.

Is one of these settings incorrect?
capture

@Ebola16
Copy link
Member Author

Ebola16 commented Feb 21, 2019

Manually fixed the lint errors 😒
Ready for review

Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

Not a big fan of the way the log types are completely duplicated… Now anyone who wants to add, remove or edit a log type has to update both the C++ code and the Android code, which is unnecessarily time-consuming and error-prone.

The log file configuration keys also shouldn't be duplicated.

Instead, you should interact with the LogManager to query and set log-related settings, log type names and descriptions, etc. I'd recommend looking at DolphinQt's LogConfigWidget.

@Ebola16 Ebola16 changed the title Android: Add Log Configuration to UI [WIP] Android: Add Log Configuration to UI Aug 30, 2019
@Ebola16 Ebola16 force-pushed the Log branch 2 times, most recently from 890f3dc to dd42e0e Compare April 7, 2020 15:27
@Ebola16 Ebola16 closed this Apr 28, 2020
@Ebola16 Ebola16 reopened this Apr 28, 2020
@delroth delroth marked this pull request as draft May 4, 2020 00:01
@Ebola16 Ebola16 force-pushed the Log branch 4 times, most recently from 7825dd7 to 7a8ab60 Compare May 7, 2020 11:47
@Ebola16 Ebola16 marked this pull request as ready for review May 7, 2020 12:04
@Ebola16 Ebola16 changed the title [WIP] Android: Add Log Configuration to UI Android: Add Log Configuration to UI May 7, 2020
@sepalani
Copy link
Contributor

It's working as expected even with debug logs (I had to build my own APK with the CMake flag -DCMAKE_BUILD_TYPE=Debug, though). You should probably hide the "debug" verbosity based on the Common::Log::MAX_LOGLEVEL like Dolphin on PC.

@Ebola16
Copy link
Member Author

Ebola16 commented Jun 17, 2020

@sepalani Let me know if you want me to squash the commits after review.

@sepalani
Copy link
Contributor

It's a bit sad that you have to duplicate these arrays to handle this case. Though, I don't think there is much you can do without changing the way these SettingsItem classes work and how tied they are with Android resources which are read-only.

Otherwise, this change looks fine to me. I also don't mind having these as two commits as they make sense separated. If you feel they don't, feel free to squash them together.

@Ebola16
Copy link
Member Author

Ebola16 commented Jun 21, 2020

I agree that the duplication is annoying but there are other cases in Dolphin that handle this issue in the same way I did. I'd rather change them all in a separate PR in the future.

@Ebola16 Ebola16 force-pushed the Log branch 2 times, most recently from 815775c to 4b10c13 Compare June 27, 2020 02:56
@Ebola16
Copy link
Member Author

Ebola16 commented Jun 30, 2020

Can we can get this merged too? It'll help with debugging issues.

Copy link
Member

@JosJuice JosJuice left a comment

Choose a reason for hiding this comment

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

I reviewed the C++ side of the PR.

Source/Android/jni/MainAndroid.cpp Outdated Show resolved Hide resolved
Source/Android/jni/MainAndroid.cpp Outdated Show resolved Hide resolved
Source/Core/Common/Logging/LogManager.cpp Outdated Show resolved Hide resolved
Source/Core/Common/Logging/LogManager.cpp Outdated Show resolved Hide resolved
@Ebola16 Ebola16 force-pushed the Log branch 2 times, most recently from 4198480 to 97d42f7 Compare July 22, 2020 02:38
@Ebola16
Copy link
Member Author

Ebola16 commented Jul 22, 2020

@JosJuice I think I took care of the remaining unresolved comments but they should probably be checked again. I also took care of simple clang-tidy suggestions on the C++ side and squashed the related commits.

Copy link
Member

@JosJuice JosJuice left a comment

Choose a reason for hiding this comment

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

I would prefer if the clang-tidy fixes were applied in a different commit (or even in a different PR), since they don't have much to do with the other changes.

Source/Android/jni/AndroidCommon/IDCache.cpp Outdated Show resolved Hide resolved
Source/Android/jni/AndroidCommon/IDCache.h Outdated Show resolved Hide resolved
Source/Android/jni/MainAndroid.cpp Outdated Show resolved Hide resolved
Source/Android/jni/MainAndroid.cpp Outdated Show resolved Hide resolved
Source/Core/Common/Logging/LogManager.cpp Outdated Show resolved Hide resolved
@Ebola16
Copy link
Member Author

Ebola16 commented Jul 22, 2020

Comments addressed and Clang-Tidy changes moved to separate PR. I also added SettingsFragmentPresenter.LOG_TYPE_NAMES to hopefully handle LinkedHashMap duplication.

Copy link
Member

@JosJuice JosJuice left a comment

Choose a reason for hiding this comment

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

This should hopefully be the last review round.

Source/Android/app/src/main/res/values/arrays.xml Outdated Show resolved Hide resolved

public final class SettingsFragmentPresenter
{
private SettingsFragmentView mView;

public static final LinkedHashMap<String, String> LOG_TYPE_NAMES =
NativeLibrary.GetLogTypeNames();
Copy link
Member

Choose a reason for hiding this comment

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

Is this guaranteed to run after NativeLibrary.Initialize? I don't believe it will work correctly otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

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

From my testing I haven't seen any problems here. Should I add a method that sets this LinkedHashMap and call it with AfterDirectoryInitializationRunner.run immediately after NativeLibrary.Initialize for an abundance of caution?

Copy link
Member Author

@Ebola16 Ebola16 Jul 24, 2020

Choose a reason for hiding this comment

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

Please see the latest commit. Let's (hopefully) prevent a lot of problems with calling NativeLibrary by completing initialization before launching Settings and Emulation activities.

The last commit should also address this review comment.

Copy link
Member

Choose a reason for hiding this comment

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

I'm still not sure if there is any guarantee that things will execute in the right order. The information I can find is that static variables will be initialized when the class is loaded, but I can't find anything about when specifically classes actually are loaded.

If you are going to gate launching the settings activity behind directory initialization, please keep in mind that there already is a check for that here, and I would prefer only having one check for it for the settings (but perhaps your new location for it is better?):

Copy link
Member Author

@Ebola16 Ebola16 Jul 24, 2020

Choose a reason for hiding this comment

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

I put a breakpoint on NativeLibrary.GetLogTypeNames and indeed it was called when the class was loaded. The class is only (eventually) called through SettingsActivity.launch. I may be missing something but it seems this shouldn't cause any problems. I'll look into the second part of your response soon.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted the last commit. We eventually call DirectoryInitialization.areDolphinDirectoriesReady() for both Settings and Emulation fragments. Also, SettingsActivity.launch adds a static context so it isn't worth changing the check to there.

@Ebola16 Ebola16 force-pushed the Log branch 3 times, most recently from dc5bcef to d34fc8e Compare July 24, 2020 10:02
@JosJuice JosJuice dismissed leoetlino’s stale review July 24, 2020 11:05

Hasn't commented on the PR in months, and the problem is fixed as far as I can tell

Copy link
Member

@JosJuice JosJuice left a comment

Choose a reason for hiding this comment

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

I still don't really like relying on undocumented class loading behavior, but I suppose that the behavior isn't going to change without a point release of Android and accompanying compatibility change notes, so if the behavior is going to change in the future, we can deal with it when it happens. LGTM other than one comment.

Source/Android/app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
@JosJuice JosJuice merged commit 234eaa0 into dolphin-emu:master Aug 2, 2020
10 checks passed
@Ebola16 Ebola16 deleted the Log branch August 2, 2020 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants