Skip to content

Commit

Permalink
fix(android): avoiding code optimization issues for R8 compile
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 committed Nov 8, 2024
1 parent 1672efe commit a668d52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/android/serialization/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ android {

dependencies {
implementation deps.annotation
implementation project(':hippy-support')
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.tencent.mtt.hippy.serialization.nio.writer;

import com.tencent.mtt.hippy.utils.LogUtils;
import java.nio.ByteBuffer;

@SuppressWarnings({"unused"})
Expand Down Expand Up @@ -73,22 +74,29 @@ public void putDouble(double d) {
}

@SuppressWarnings("SpellCheckingInspection")
// After upgrading to AGP version 8 or above, R8 compilation will be started. Due to the optimization
// of R8 compilation code, it will affect the logic of the code here, causing encoding and decoding
// failures and white screen problems. Therefore, it is necessary to add some logs in the implementation
// of this function to avoid R8 compilation optimization.
@Override
public int putVarint(long l) {
if (count + 10 > value.length) {
enlargeBuffer(count + 10);
}

LogUtils.d("CallFunction", "putVarint l " + l + ", count " + count);
long rest = l;
int bytes = 0;
byte b;
do {
b = (byte) rest;
LogUtils.d("CallFunction", "putVarint origin b " + b + ", count " + count);
b |= 0x80;
LogUtils.d("CallFunction", "putVarint b " + Byte.toUnsignedInt(b) + ", count " + count);
value[count++] = b;
rest >>>= 7;
bytes++;
} while (rest != 0);
LogUtils.d("CallFunction", "putVarint bb " + Byte.toUnsignedInt((byte) (b & 0x7f)) + ", bytes " + bytes + ", count " + count);
value[count - 1] = (byte) (b & 0x7f);
return bytes;
}
Expand Down

0 comments on commit a668d52

Please sign in to comment.