android: patch getDrawable in QtActivityDelegate.java #312

Manually merged
johnny9 merged 1 commit from getDrawable into main 2023-04-17 09:49:23 +00:00 AGit
johnny9 commented 2023-04-06 01:15:43 +00:00 (Migrated from github.com)

The getDrawable method used in the QtActivityDelegate has been deprecated and causes a runtime exception. The patch updates the method to include the theme as a second parameter so it can fully resolve the resources.

Windows
Intel macOS
Apple Silicon macOS
ARM64 Android

The getDrawable method used in the QtActivityDelegate has been deprecated and causes a runtime exception. The patch updates the method to include the theme as a second parameter so it can fully resolve the resources. [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/unsecure_win_gui.zip?branch=pull/312) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/unsecure_mac_gui.zip?branch=pull/312) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/unsecure_mac_arm64_gui.zip?branch=pull/312) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/unsecure_android_apk.zip?branch=pull/312)
johnny9 commented 2023-04-06 01:16:26 +00:00 (Migrated from github.com)

This should resolve the runtime exception when calling createSurface

This should resolve the runtime exception when calling createSurface
johnny9 commented 2023-04-06 01:20:53 +00:00 (Migrated from github.com)

Update from 34d5b57 to 5116ee:

  • Fixed typo in commit message
Update from[ 34d5b57 ](https://github.com/bitcoin-core/gui-qml/commit/34d5b575f88c1e2b02123ab9d04442653d3dd3a6)to[ 5116ee](https://github.com/bitcoin-core/gui-qml/commit/5116ee96575af2a428f9bca37aa752572505de64): - Fixed typo in commit message
johnny9 commented 2023-04-06 02:18:30 +00:00 (Migrated from github.com)

@hebasto have to apply a patch in a different part of the build with this one. Want to check if you have any thoughts on it.

@hebasto have to apply a patch in a different part of the build with this one. Want to check if you have any thoughts on it.
jarolrod (Migrated from github.com) reviewed 2023-04-06 02:29:29 +00:00
jarolrod (Migrated from github.com) left a comment

Concept ACK

Will have this running to test if this crash ever occurs

Concept ACK Will have this running to test if this crash ever occurs
hebasto commented 2023-04-10 13:53:02 +00:00 (Migrated from github.com)

Mind providing more context please?

The getDrawable method used in the QtActivityDelegate has been deprecated

When has it been deprecated? In which Qt version?

... and causes a runtime exception.

Why does our implementation rely on a deprecated method?

The patch updates the method to include the theme as a second parameter so it can fully resolve the resources.

Is this patch available upstream?

Mind providing more context please? > The getDrawable method used in the QtActivityDelegate has been deprecated When has it been deprecated? In which Qt version? > ... and causes a runtime exception. Why does our implementation rely on a deprecated method? > The patch updates the method to include the theme as a second parameter so it can fully resolve the resources. Is this patch available upstream?
johnny9 commented 2023-04-11 00:21:07 +00:00 (Migrated from github.com)

Mind providing more context please?

The getDrawable method used in the QtActivityDelegate has been deprecated

When has it been deprecated? In which Qt version?

... and causes a runtime exception.

Why does our implementation rely on a deprecated method?

The patch updates the method to include the theme as a second parameter so it can fully resolve the resources.

Is this patch available upstream?

The function is deprecated in Android. https://developer.android.com/reference/android/content/res/Resources#getDrawable(int). The deprecated function is used in QtActivityDelegate.java which is a class provided by the Qt 5.15 source code. We pull it directly from the tarball and our BitcoinQtActivity derives from this class. The specific method causes a crash on the versions of android we have tested(8 and 13).

It was fixed in Qt 6.4 with this patch github.com/qt/qtbase@e80b0f3d87 this patch doesn't directly apply to Qt 5.15 so I've created the patch myself.

> Mind providing more context please? > > > The getDrawable method used in the QtActivityDelegate has been deprecated > > When has it been deprecated? In which Qt version? > > > ... and causes a runtime exception. > > Why does our implementation rely on a deprecated method? > > > The patch updates the method to include the theme as a second parameter so it can fully resolve the resources. > > Is this patch available upstream? The function is deprecated in Android. https://developer.android.com/reference/android/content/res/Resources#getDrawable(int). The deprecated function is used in QtActivityDelegate.java which is a class provided by the Qt 5.15 source code. We pull it directly from the tarball and our BitcoinQtActivity derives from this class. The specific method causes a crash on the versions of android we have tested(8 and 13). It was fixed in Qt 6.4 with this patch https://github.com/qt/qtbase/commit/e80b0f3d87a6f702b9d1d58068f8cc714c163c01 this patch doesn't directly apply to Qt 5.15 so I've created the patch myself.
johnny9 commented 2023-04-11 04:03:25 +00:00 (Migrated from github.com)

Update from 5116ee9 to 459ebac

Update from[ 5116ee9 ](https://github.com/bitcoin-core/gui-qml/commit/5116ee96575af2a428f9bca37aa752572505de64)to 459ebac - Patched additional getDrawable call found in QtActivityDelegate.java to match https://github.com/qt/qtbase/commit/e80b0f3d87a6f702b9d1d58068f8cc714c163c01
hebasto commented 2023-04-11 10:15:15 +00:00 (Migrated from github.com)

Mind providing more context please?

The getDrawable method used in the QtActivityDelegate has been deprecated

When has it been deprecated? In which Qt version?

... and causes a runtime exception.

Why does our implementation rely on a deprecated method?

The patch updates the method to include the theme as a second parameter so it can fully resolve the resources.

Is this patch available upstream?

The function is deprecated in Android. https://developer.android.com/reference/android/content/res/Resources#getDrawable(int). The deprecated function is used in QtActivityDelegate.java which is a class provided by the Qt 5.15 source code. We pull it directly from the tarball and our BitcoinQtActivity derives from this class. The specific method causes a crash on the versions of android we have tested(8 and 13).

It was fixed in Qt 6.4 with this patch qt/qtbase@e80b0f3 this patch doesn't directly apply to Qt 5.15 so I've created the patch myself.

Thanks!

Mind putting these useful details into the PR description?

From https://bugreports.qt.io/browse/QTBUG-103568, it follows that a patch for Qt 5.15 does exist. But only for 5.15.11 which is source-closed for now.

Going to review your patch shortly.

> > Mind providing more context please? > > > The getDrawable method used in the QtActivityDelegate has been deprecated > > > > > > When has it been deprecated? In which Qt version? > > > ... and causes a runtime exception. > > > > > > Why does our implementation rely on a deprecated method? > > > The patch updates the method to include the theme as a second parameter so it can fully resolve the resources. > > > > > > Is this patch available upstream? > > The function is deprecated in Android. https://developer.android.com/reference/android/content/res/Resources#getDrawable(int). The deprecated function is used in QtActivityDelegate.java which is a class provided by the Qt 5.15 source code. We pull it directly from the tarball and our BitcoinQtActivity derives from this class. The specific method causes a crash on the versions of android we have tested(8 and 13). > > It was fixed in Qt 6.4 with this patch [qt/qtbase@e80b0f3](https://github.com/qt/qtbase/commit/e80b0f3d87a6f702b9d1d58068f8cc714c163c01) this patch doesn't directly apply to Qt 5.15 so I've created the patch myself. Thanks! Mind putting these useful details into the PR description? From https://bugreports.qt.io/browse/QTBUG-103568, it follows that a patch for Qt 5.15 does exist. But only for 5.15.11 which is source-closed for now. Going to review your patch shortly.
hebasto (Migrated from github.com) reviewed 2023-04-11 10:45:37 +00:00
hebasto (Migrated from github.com) left a comment

Concept ACK.

It was fixed in Qt 6.4 with this patch qt/qtbase@e80b0f3

It looks like the upstream fix is github.com/qt/qtbase@e07fea6fb4. The mentioned commit is a backport to the 6.4 branch.

Concept ACK. > It was fixed in Qt 6.4 with this patch [qt/qtbase@e80b0f3](https://github.com/qt/qtbase/commit/e80b0f3d87a6f702b9d1d58068f8cc714c163c01) It looks like the upstream fix is https://github.com/qt/qtbase/commit/e07fea6fb405c6e9affe6e377ad99a98a740c5be. The mentioned commit is a backport to the 6.4 branch.
hebasto (Migrated from github.com) commented 2023-04-11 10:40:04 +00:00
Android 13: Fix warnings on starting an application

On Android 13, currently in beta, android triggers a warning because it
is using a deprecated getDrawable function.
The patch changes it to use the non-deprecated alternative as suggested
in the warning.

Fixes: QTBUG-103568

Upstream commits:
 - Qt 5.15.11 backport: unavailable
 - Qt 6.5: e07fea6fb405c6e9affe6e377ad99a98a740c5be


--- old/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ new/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
```suggestion Android 13: Fix warnings on starting an application On Android 13, currently in beta, android triggers a warning because it is using a deprecated getDrawable function. The patch changes it to use the non-deprecated alternative as suggested in the warning. Fixes: QTBUG-103568 Upstream commits: - Qt 5.15.11 backport: unavailable - Qt 6.5: e07fea6fb405c6e9affe6e377ad99a98a740c5be --- old/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ new/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java ```
hebasto (Migrated from github.com) commented 2023-04-11 10:41:07 +00:00

Please move patching into qt.mk:

--- a/depends/packages/qt.mk
+++ b/depends/packages/qt.mk
@@ -24,6 +24,7 @@ $(package)_patches += fast_fixed_dtoa_no_optimize.patch
 $(package)_patches += guix_cross_lib_path.patch
 $(package)_patches += fix_android_plugin_names.patch
 $(package)_patches += fix_riscv_atomic.patch
+$(package)_patches += fix_android_get_drawable.patch
 
 $(package)_qtdeclarative_file_name = qtdeclarative-$($(package)_suffix)
 $(package)_qtdeclarative_sha256_hash = 5cc169d91efb15a1ee7f484862f872c3eaba592dacf3c0fbcb55c0f3c208254a
@@ -294,6 +295,7 @@ define $(package)_preprocess_cmds
   patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \
   patch -p1 -i $($(package)_patch_dir)/fix_android_plugin_names.patch && \
   patch -p1 -i $($(package)_patch_dir)/fix_riscv_atomic.patch && \
+  patch -p1 -i $($(package)_patch_dir)/fix_android_get_drawable.patch && \
   mkdir -p qtbase/mkspecs/macx-clang-linux &&\
   cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
   cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \
Please move patching into `qt.mk`: ```diff --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -24,6 +24,7 @@ $(package)_patches += fast_fixed_dtoa_no_optimize.patch $(package)_patches += guix_cross_lib_path.patch $(package)_patches += fix_android_plugin_names.patch $(package)_patches += fix_riscv_atomic.patch +$(package)_patches += fix_android_get_drawable.patch $(package)_qtdeclarative_file_name = qtdeclarative-$($(package)_suffix) $(package)_qtdeclarative_sha256_hash = 5cc169d91efb15a1ee7f484862f872c3eaba592dacf3c0fbcb55c0f3c208254a @@ -294,6 +295,7 @@ define $(package)_preprocess_cmds patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \ patch -p1 -i $($(package)_patch_dir)/fix_android_plugin_names.patch && \ patch -p1 -i $($(package)_patch_dir)/fix_riscv_atomic.patch && \ + patch -p1 -i $($(package)_patch_dir)/fix_android_get_drawable.patch && \ mkdir -p qtbase/mkspecs/macx-clang-linux &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ ```
johnny9 (Migrated from github.com) reviewed 2023-04-11 12:29:34 +00:00
johnny9 (Migrated from github.com) commented 2023-04-11 12:29:34 +00:00

Thank you for the suggestions and finding the upstream patch. The problem with just patching here is that it gets overwritten by github.com/bitcoin-core/gui-qml@3abea89591/src/Makefile.qt.include (L522)

Thank you for the suggestions and finding the upstream patch. The problem with just patching here is that it gets overwritten by https://github.com/bitcoin-core/gui-qml/blob/3abea8959147af63c5bed06336c2ab27fa6d3c64/src/Makefile.qt.include#L522
hebasto (Migrated from github.com) reviewed 2023-04-11 14:44:57 +00:00
hebasto (Migrated from github.com) commented 2023-04-11 14:44:57 +00:00

I see. Might be good to add a comment then?

I see. Might be good to add a comment then?
hebasto (Migrated from github.com) reviewed 2023-04-11 15:19:14 +00:00
hebasto (Migrated from github.com) left a comment

Approach ACK 459ebacd8595ff5e3e0529183588e61d9f521662

@jarolrod Can you confirm that this PR fixes the issue?

Approach ACK 459ebacd8595ff5e3e0529183588e61d9f521662 @jarolrod Can you confirm that this PR fixes the issue?
johnny9 commented 2023-04-12 02:40:40 +00:00 (Migrated from github.com)

Update from 459ebac to f1fedfe

  • Added upstream comment to the patch
Update from[ 459ebac ](https://github.com/bitcoin-core/gui-qml/commit/459ebacd8595ff5e3e0529183588e61d9f521662)to f1fedfe - Added upstream comment to the patch
hebasto (Migrated from github.com) approved these changes 2023-04-12 12:01:12 +00:00
hebasto (Migrated from github.com) left a comment

ACK f1fedfebcc, I have reviewed the code and it looks OK, the patch applies cleanly. Did not test on Android.

ACK f1fedfebcc074a6526d1ec3ce6ab26d744038623, I have reviewed the code and it looks OK, the patch applies cleanly. Did not test on Android.
hebasto commented 2023-04-16 07:48:19 +00:00 (Migrated from github.com)

@jarolrod Can you confirm that this PR fixes the issue?

ping :)

> @jarolrod Can you confirm that this PR fixes the issue? ping :)
jarolrod (Migrated from github.com) approved these changes 2023-04-17 02:04:46 +00:00
jarolrod (Migrated from github.com) left a comment

ACK f1fedfebcc

Testing now with proper cpu and wifi locks, I know believe this was more of a warning than a bug. But this is now gone with the patch.

ACK f1fedfebcc074a6526d1ec3ce6ab26d744038623 Testing now with proper cpu and wifi locks, I know believe this was more of a warning than a bug. But this is now gone with the patch.
Sign in to join this conversation.
No description provided.