Sentaroh/SMBSync2

Wifi specific IP bugs

Closed this issue · 9 comments

Hi,
With the recent changes made to the Wifi/IP, there are now a few annoying bugs:

1- When a new smb task is created, the Wifi prompt option is not displayed when saving the SMB server settings. The Wifi option menu is not present until we save the task and edit the task again

No Wifi Option:
Screenshot_1609871161

2- "Has Private Address" is no longer selectable because of an error in the way the index numbers were changed in last commit

I did not try to fix them as in my opinion you cannot fix the code that way. This causes a crash when updating old versions of SMBSync2 to a new one: if old version has "Specific IP" option enabled, when you update to new versions and try to edit the IP address list, app will crash

The only proper way is:

  • remove support of the "Wifi AP list" like you did but you MUST KEEP THE INDEX NUMBERS. You cannot decide that when list == 2 --> change it to 3 or when it is 3 change it to 2 because this will not detect older/new version and will not respect user settings. It could have been possible if Wifi AP List was index=4 (last one). But since it is not the last one, you cannot remove it. You must keep the internal indexes 0, 1, 2, 3, 4 AND if index selected ==2, set the task in error mode (color red and sync disabled) so that user manually changes to allowed options

Let me know if you need me to try to fix it properly ?

Best regards

About the crash I reported:
I can only reproduce it on two devices, but with the existing config, so cannot reproduce it as I do not know the cause:

1- existing task with "IP list" containing one existing IP
2- click on the existing IP entry
3- instant crash:

Debug code I could get

2021-01-05 20:55:20.694 1648-1648/? D/AndroidRuntime: Shutting down VM
2021-01-05 20:55:20.695 1648-1648/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.sentaroh.android.SMBSync2, PID: 1648
    java.lang.StringIndexOutOfBoundsException: length=44; index=45
        at java.lang.String.substring(String.java:2060)
        at java.lang.String.subSequence(String.java:2107)
        at android.widget.TextView.onProvideStructure(TextView.java:12710)
        at android.view.View.onProvideAutofillStructure(View.java:9203)
        at android.view.View.dispatchProvideStructure(View.java:10084)
        at android.view.View.dispatchProvideAutofillStructure(View.java:10077)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.app.assist.AssistStructure$WindowNode.<init>(AssistStructure.java:527)
        at android.app.assist.AssistStructure.<init>(AssistStructure.java:2154)
        at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3917)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2215)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
2021-01-05 20:55:20.696 1065-8975/? I/DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
2021-01-05 20:55:20.696 1065-10658/? D/Debug: !@DumpState : SHIP
2021-01-05 20:55:20.696 1065-10658/? D/Debug: !@DumpState : debug level:0x4f4c
2021-01-05 20:55:20.697 1065-10658/? D/Debug: !@Dumpstate : Finally, system will skip dumpstate
2021-01-05 20:55:20.697 1065-10658/? W/ActivityManager: crash : com.sentaroh.android.SMBSync2,0
2021-01-05 20:55:20.698 1065-10658/? W/ActivityTaskManager:   Force finishing activity com.sentaroh.android.SMBSync2/.ActivityMain

The relevant part I see is:
java.lang.StringIndexOutOfBoundsException: length=44; index=45

The faulty dialog message is:
Les filtres suivants existent déjà: 10.5.5.45 which has a 45 chars length

Is the dialog index set somewhere to 44 or wrongly calculated to length-1 ?

And here's the debug code from the Android Studio App with the debug apk running on the Galaxy S20 device crashing:

2021-01-05 21:48:16.948 31892-31892/com.sentaroh.android.SMBSync2 D/AndroidRuntime: Shutting down VM
2021-01-05 21:48:16.949 31892-31892/com.sentaroh.android.SMBSync2 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.sentaroh.android.SMBSync2, PID: 31892
    java.lang.StringIndexOutOfBoundsException: length=44; index=45
        at java.lang.String.substring(String.java:2060)
        at java.lang.String.subSequence(String.java:2107)
        at android.widget.TextView.onProvideStructure(TextView.java:12710)
        at android.view.View.onProvideAutofillStructure(View.java:9203)
        at android.view.View.dispatchProvideStructure(View.java:10084)
        at android.view.View.dispatchProvideAutofillStructure(View.java:10077)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.app.assist.AssistStructure$WindowNode.<init>(AssistStructure.java:527)
        at android.app.assist.AssistStructure.<init>(AssistStructure.java:2154)
        at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3917)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2215)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
2021-01-05 21:48:16.964 31892-31892/com.sentaroh.android.SMBSync2 I/Process: Sending signal. PID: 31892 SIG: 9

I really suspect this line:

private void editFilter(..)
    dlg_msg.setText(mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified, filter))

A last one, starting at the exact moment I try to add a new entry, by clicking on the Text Field in front of the Add button:

2021-01-05 21:57:30.604 7824-7824/com.sentaroh.android.SMBSync2 I/ViewRootImpl@4e44db6[ActivityMain]: ViewPostIme pointer 0
2021-01-05 21:57:30.618 7824-8325/com.sentaroh.android.SMBSync2 D/OpenGLRenderer: makeCurrent EglSurface : 0x7dc120e580 -> 0x7dc140ae80
2021-01-05 21:57:30.769 7824-7824/com.sentaroh.android.SMBSync2 I/ViewRootImpl@4e44db6[ActivityMain]: ViewPostIme pointer 1
2021-01-05 21:57:30.787 7824-7824/com.sentaroh.android.SMBSync2 D/InputMethodManager: prepareNavigationBarInfo() DecorView@97388e8[ActivityMain]
2021-01-05 21:57:30.787 7824-7824/com.sentaroh.android.SMBSync2 D/InputMethodManager: getNavigationBarColor() -16777216
2021-01-05 21:57:30.787 7824-7824/com.sentaroh.android.SMBSync2 V/InputMethodManager: Starting input: tba=com.sentaroh.android.SMBSync2 ic=com.android.internal.widget.EditableInputConnection@e7fe069 mNaviBarColor -16777216 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
2021-01-05 21:57:30.787 7824-7824/com.sentaroh.android.SMBSync2 D/InputMethodManager: startInputInner - Id : 0
2021-01-05 21:57:30.793 7824-7824/com.sentaroh.android.SMBSync2 I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
2021-01-05 21:57:30.795 7824-7824/com.sentaroh.android.SMBSync2 D/InputTransport: Input channel destroyed: 'ClientS', fd=97
2021-01-05 21:57:30.795 7824-7824/com.sentaroh.android.SMBSync2 D/InputMethodManager: SSI - flag : 0 Pid : 7824 view : com.sentaroh.android.SMBSync2
2021-01-05 21:57:30.796 7824-7824/com.sentaroh.android.SMBSync2 D/InputMethodManager: prepareNavigationBarInfo() DecorView@97388e8[ActivityMain]
2021-01-05 21:57:30.796 7824-7824/com.sentaroh.android.SMBSync2 D/InputMethodManager: getNavigationBarColor() -16777216
2021-01-05 21:57:30.800 7824-7824/com.sentaroh.android.SMBSync2 D/Editor: waiting for the right moment
2021-01-05 21:57:30.860 7824-7824/com.sentaroh.android.SMBSync2 D/AndroidRuntime: Shutting down VM
2021-01-05 21:57:30.863 7824-7824/com.sentaroh.android.SMBSync2 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.sentaroh.android.SMBSync2, PID: 7824
    java.lang.StringIndexOutOfBoundsException: length=42; index=43
        at java.lang.String.substring(String.java:2060)
        at java.lang.String.subSequence(String.java:2107)
        at android.widget.TextView.onProvideStructure(TextView.java:12710)
        at android.view.View.onProvideAutofillStructure(View.java:9203)
        at android.view.View.dispatchProvideStructure(View.java:10084)
        at android.view.View.dispatchProvideAutofillStructure(View.java:10077)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.view.ViewGroup.dispatchProvideAutofillStructure(ViewGroup.java:4424)
        at android.app.assist.AssistStructure$WindowNode.<init>(AssistStructure.java:527)
        at android.app.assist.AssistStructure.<init>(AssistStructure.java:2154)
        at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3917)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2215)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
2021-01-05 21:57:30.881 7824-7824/com.sentaroh.android.SMBSync2 I/Process: Sending signal. PID: 7824 SIG: 9

This time:
java.lang.StringIndexOutOfBoundsException: length=42; index=43

Not sure why this length=42 on the empty field

Maybe it is all related to a corrupted config because of the buggy filter index ?

If I create a new task from scratch, the crash is solved
Here are the two tasks as in the Autosave settings file:

PROF 8S	Galaxy S20 Sdcard to NAS	1	M	INT									SMB			RemoteSync	Galaxy S20/Sdcard	10.0.0.41				[E.thumbdata*]	[E\.cache/	E\.thumbdata/	E\.thumbnails/	E\cache/]									[]	[I10.0.0.62]	1	1	0	0	0	3	1	1	1	1	0	0	1	1	-	4	2020/12/07 19:00:04	2	0	-	-			0	0	0		NORMAL	DEFLATE	NONE		1	0	0	-	-	UTF-8	1	1	/storage/emulated/0			4	4	1	1	DSC_%DATE%	1	5	0	4	%YEAR%	1	0	0	1	0	0	1	0	0	0	0	0	0	0	0	0	3	1	60	1	1	end
PROF 8S	test					1	C	INT									SMB			share		dir					server					[]				[]																						[]	[I10.0.0.62]	1	1	1	0	0	3	1	1	1	1	0	0	3	1	-	4	0					2	-	-	0			0	0		NORMAL	DEFLATE	NONE		0	0	0	-	-	UTF-8	1	1	/storage/emulated/0	/storage/emulated/0		5	5	1	1	DSC_%DATE%	1	5	0	4	%YEAR%	1	0	0	1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	60	0	0	end

First task crashes, second one freshly created works
Do you think it is because of an old settings file migration ? Is the crash related to a bug somewhere in the SMBSync2 sources ? All my tracing couldn't find the exact cause. The settings file looks proper from the above sample. I really suspect the last changes in filter index because that's clearly a bug that would cause issues as it is now because it links some data to another data field

Thank you.

1- When a new smb task is created, the Wifi prompt option is not displayed when saving the SMB server settings. The Wifi option menu is not present until we save the task and edit the task again
2- "Has Private Address" is no longer selectable because of an error in the way the index numbers were changed in last commit

Fixed above bug.(https://github.com/Sentaroh/SMBSync2/tree/2.47-1-fix-wifi-ap-list-bug)

java.lang.StringIndexOutOfBoundsException: length=44; index=45

I can recreate app crash.
We will continue our investigation.

First task crashes, second one freshly created works

I can create app crash with your task list and Removed edit_wifi_ap_list related code.

Best regards.

Thank you for the fixes.
I committed a patch to use the SyncTask Error state app function. Bad task is detected on first app launch and shown to user since this is a major change impacting old users

Screenshot_1609941689

Note: in fact, by using the settings file from the Galaxy S20, I now can reproduce the String.java crash in emulator. However, I could not figure the issue. I let you look at it and I will be looking at your fix to test it once you figure it out.

best regards

Thank you.

java.lang.StringIndexOutOfBoundsException: length=44; index=45

For the first task in your task list, if you remove the File filter and Directory filter, the problem disappears. However, if I register another Filter, the problem reappears.
I will continue to investigate.

Best regards.

Hi,

Fixed the NonWordwrapButton/NonWordwrapTextView bug, so I changed the Master/Target button back to NonWordwrapButton.

Best regards.

This is really a great catch, thank you
I was trying to figure it since a few hours. I noticed the crash would happen when smb://server_name/share_name/dir_name wraps in the button. However, I did not look at the WordWrapButton.

I can confirm now it works on the emulator and the Galaxy S20 with Android 11

Best regards